Class WingsJooqUtil

  • All Implemented Interfaces:

    
    public class WingsJooqUtil
    extends DSL
                        
    Since:

    2020-06-01

    Author:

    trydofor

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      public class WingsJooqUtil.CondBuilder

      Friendly chained condition builder

      (1=1) and ((2=2 or 3=3) or (4=4 and 5=5))
      can be done by grp-end as follows
      (1=1).and()
      .grp()
         .grp(2=2).or(3=3).end()
             .and()
         .grp(4=4).or(5=5).end()
      .end()
      
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      WingsJooqUtil()
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      static Array<Field<out Object>> primaryKeys(Table<out Object> table)
      static void skipFields(TableRecord<out Object> record, Array<Field<out Object>> fields)
      static void skipNullVals(TableRecord<out Object> record)
      static Field<String> concatWs(String separator, Array<Object> vals) CONCAT_WS(separator,str1,str2,...
      static RowCountQuery replaceInto(TableRecord<out Object> record) CUD listener does not trigger
      static RowCountQuery replaceInto(Table<out Object> table, Array<Field<out Object>> fields) CUD listener does not trigger
      static Condition condAsEmpty(@NotNull() Field<LocalDateTime> datetime) datetime <DATE_TIME_AS_MAX
      static Condition condNonEmpty(@NotNull() Field<LocalDateTime> datetime) datetime >DATE_TIME_AS_MAX
      static Condition condMatch(String against, Array<Field<out Object>> fields) MATCH (a) AGAINST ('abc')
      static <Z> Condition condEqSkip(Field<Z> filed, Collection<Z> value) Return NoCondition if value is null, otherwise return eq(NotNull)
      static <Z> Condition condEqSkip(Field<Z> filed, Collection<Z> value, Predicate<Z> filter) Return NoCondition if filter is true, otherwise return eq(NotNull)
      static <Z> Condition condInSkip(Field<Z> filed, Collection<Z> value) Return NoCondition if value is null, otherwise return in(NotNull)
      static <Z> Condition condInSkip(Field<Z> filed, Collection<Z> value, Predicate<Z> filter) Return NoCondition if filter is true, otherwise return in(NotNull)
      static <Z> Condition condRange(Field<Z> field, Z lowerInclusive, Z upperInclusive) Return a between condition
      static Condition condChain(TableRecord<out Object> record)
      static Condition condChain(TableRecord<out Object> record, boolean ignoreNull)
      static Condition condChain(Operator andOr, TableRecord<out Object> record)
      static Condition condChain(Operator andOr, TableRecord<out Object> record, boolean ignoreNull) Return a condition join by and/or with the record, e.g.
      static Condition condChain(Map<String, Object> fieldValue)
      static Condition condChain(Map<String, Object> fieldValue, boolean ignoreNull)
      static Condition condChain(Map<String, Object> fieldValue, boolean ignoreNull, TableImpl<out Object> alias)
      static Condition condChain(Operator andOr, Map<String, Object> fieldValue, boolean ignoreNull)
      static Condition condChain(Operator andOr, Map<String, Object> fieldValue, boolean ignoreNull, TableImpl<out Object> alias) Return a condition join by and/or with the field map use `f.in(v)` if value is collection, otherwise `f.
      static Condition condField(Field<out Object> field, boolean ignoreNull, Object value)
      filed is null -> throw
      value is Array | Coolection -> f.in(v)
      null && !ignore -> f.isNull()
      _ -> f.eq(v)
      
      static List<Condition> condField(TableRecord<out Object> record, Array<Field<out Object>> includes)
      static List<Condition> condField(TableRecord<out Object> record, boolean ignoreNull, Array<Field<out Object>> includes) Return a condition by record and specified fileds.
      static WingsJooqUtil.CondBuilder condBuilder() Friendly chained condition builder
      static WingsJooqUtil.CondBuilder condBuilder(Condition cond) Friendly chained condition builder
      static Array<Param<out Object>> bindValue(TableRecord<out Object> record)
      static Array<Param<out Object>> bindValue(TableRecord<out Object> record, boolean ignoreNull)
      static Array<Param<out Object>> bindNamed(TableRecord<out Object> record)
      static Array<Param<out Object>> bindNamed(TableRecord<out Object> record, boolean ignoreNull)
      static Array<Param<out Object>> bindNamed(Map<String, Object> bindings)
      static Array<Param<out Object>> bindNamed(Map<String, Object> bindings, boolean ignoreNull)
      • Methods inherited from class org.jooq.impl.DSL

        abs, acos, acosh, acoth, aggregate, aggregateDistinct, all, all, alterDatabase, alterDatabaseIfExists, alterDomain, alterDomainIfExists, alterIndex, alterIndexIfExists, alterMaterializedView, alterMaterializedViewIfExists, alterSchema, alterSchemaIfExists, alterSequence, alterSequence, alterSequenceIfExists, alterSequenceIfExists, alterTable, alterTableIfExists, alterType, alterTypeIfExists, alterView, alterViewIfExists, and, any, any, anyValue, array, arrayAgg, arrayAggDistinct, arrayAppend, arrayConcat, arrayGet, arrayOverlap, arrayPrepend, arrayRemove, arrayReplace, ascii, asin, asinh, asterisk, atan, atan2, atanh, avg, avgDistinct, begin, bitAnd, bitAndAgg, bitCount, bitGet, bitLength, bitNand, bitNandAgg, bitNor, bitNorAgg, bitNot, bitOr, bitOrAgg, bitSet, bitXNor, bitXNorAgg, bitXor, bitXorAgg, boolAnd, boolOr, cardinality, case_, case_, cast, castNull, catalog, ceil, century, charLength, characterSet, check, choose, choose, choose, chr, coalesce, coerce, collation, comment, commentOnColumn, commentOnMaterializedView, commentOnTable, commentOnView, commit, concat, condition, constraint, corr, cos, cosh, cot, coth, count, countDistinct, covarPop, covarSamp, createDatabase, createDatabaseIfNotExists, createDomain, createDomainIfNotExists, createGlobalTemporaryTable, createGlobalTemporaryTableIfNotExists, createIndex, createIndexIfNotExists, createMaterializedView, createMaterializedViewIfNotExists, createOrReplaceMaterializedView, createOrReplaceView, createSchema, createSchemaIfNotExists, createSequence, createSequenceIfNotExists, createTable, createTableIfNotExists, createTemporaryTable, createTemporaryTableIfNotExists, createType, createTypeIfNotExists, createUniqueIndex, createUniqueIndexIfNotExists, createView, createViewIfNotExists, cube, cumeDist, cumeDist, currentCatalog, currentDate, currentInstant, currentLocalDate, currentLocalDateTime, currentLocalTime, currentOffsetDateTime, currentOffsetTime, currentSchema, currentTime, currentTimestamp, currentUser, date, dateAdd, dateDiff, dateSub, day, dayOfWeek, dayOfYear, decade, decode, decode, defaultValue, defaultValue, default_, default_, deg, delete, deleteFrom, denseRank, denseRank, digits, domain, domain, dropDatabase, dropDatabaseIfExists, dropDomain, dropDomainIfExists, dropIndex, dropIndexIfExists, dropMaterializedView, dropMaterializedViewIfExists, dropSchema, dropSchemaIfExists, dropSequence, dropSequenceIfExists, dropTable, dropTableIfExists, dropTemporaryTable, dropTemporaryTableIfExists, dropType, dropTypeIfExists, dropView, dropViewIfExists, dual, e, emptyGroupingSet, epoch, escape, escape, every, excluded, exists, exp, extract, falseCondition, field, field, field, field, finalTable, firstValue, floor, foreignKey, foreignKey, foreignKey, foreignKey, foreignKey, foreignKey, foreignKey, foreignKey, foreignKey, foreignKey, foreignKey, foreignKey, foreignKey, foreignKey, foreignKey, foreignKey, foreignKey, foreignKey, foreignKey, foreignKey, foreignKey, foreignKey, foreignKey, foreignKey, foreignKey, foreignKey, foreignKey, foreignKey, foreignKey, foreignKey, foreignKey, foreignKey, foreignKey, foreignKey, foreignKey, foreignKey, foreignKey, foreignKey, foreignKey, foreignKey, foreignKey, foreignKey, foreignKey, foreignKey, foreignKey, function, generateSeries, getDataType, grant, greatest, groupConcat, groupConcat, groupConcatDistinct, grouping, groupingSets, groupsBetweenCurrentRow, groupsBetweenFollowing, groupsBetweenPreceding, groupsBetweenUnboundedFollowing, groupsBetweenUnboundedPreceding, groupsCurrentRow, groupsFollowing, groupsPreceding, groupsUnboundedFollowing, groupsUnboundedPreceding, hour, if_, ifnull, iif, in, inOut, index, inline, inline, inline, inline, inline, inline, inline, inline, inline, inline, inline, inline, inline, inline, inline, inline, inline, inline, inline, inline, inline, inline, inline, inline, inline, inline, inline, inline, inline, inlined, inlined, inlined, insert, insertInto, insertInto, insertInto, insertInto, insertInto, insertInto, insertInto, insertInto, insertInto, insertInto, insertInto, insertInto, insertInto, insertInto, insertInto, insertInto, insertInto, insertInto, insertInto, insertInto, insertInto, insertInto, insertInto, insertInto, instant, isnull, isoDayOfWeek, jsonArray, jsonArrayAgg, jsonArrayAggDistinct, jsonEntry, jsonExists, jsonGetAttribute, jsonGetAttributeAsText, jsonGetElement, jsonGetElementAsText, jsonInsert, jsonKeys, jsonObject, jsonObjectAgg, jsonRemove, jsonReplace, jsonSet, jsonTable, jsonValue, jsonbArray, jsonbArrayAgg, jsonbArrayAggDistinct, jsonbExists, jsonbGetAttribute, jsonbGetAttributeAsText, jsonbGetElement, jsonbGetElementAsText, jsonbInsert, jsonbKeys, jsonbObject, jsonbObjectAgg, jsonbRemove, jsonbReplace, jsonbSet, jsonbTable, jsonbValue, key, keyword, lag, lastValue, lateral, lead, least, left, length, list, listAgg, listAggDistinct, ln, localDate, localDateAdd, localDateDiff, localDateSub, localDateTime, localDateTimeAdd, localDateTimeDiff, localDateTimeDiff, localDateTimeSub, localTime, log, log10, lower, lpad, ltrim, max, maxDistinct, md5, median, mergeInto, mergeInto, mergeInto, mergeInto, mergeInto, mergeInto, mergeInto, mergeInto, mergeInto, mergeInto, mergeInto, mergeInto, mergeInto, mergeInto, mergeInto, mergeInto, mergeInto, mergeInto, mergeInto, mergeInto, mergeInto, mergeInto, mergeInto, mergeInto, microsecond, mid, millennium, millisecond, min, minDistinct, minus, minute, mode, mode, month, multiset, multisetAgg, multisetAgg, multisetAgg, multisetAgg, multisetAgg, multisetAgg, multisetAgg, multisetAgg, multisetAgg, multisetAgg, multisetAgg, multisetAgg, multisetAgg, multisetAgg, multisetAgg, multisetAgg, multisetAgg, multisetAgg, multisetAgg, multisetAgg, multisetAgg, multisetAgg, multisetAgg, multisetAggDistinct, multisetAggDistinct, multisetAggDistinct, multisetAggDistinct, multisetAggDistinct, multisetAggDistinct, multisetAggDistinct, multisetAggDistinct, multisetAggDistinct, multisetAggDistinct, multisetAggDistinct, multisetAggDistinct, multisetAggDistinct, multisetAggDistinct, multisetAggDistinct, multisetAggDistinct, multisetAggDistinct, multisetAggDistinct, multisetAggDistinct, multisetAggDistinct, multisetAggDistinct, multisetAggDistinct, multisetAggDistinct, name, neg, newTable, noCondition, noField, noField, noTable, not, not, notExists, notUnique, now, nthValue, ntile, nullCondition, nullif, nvl, nvl2, octetLength, offsetDateTime, offsetTime, oldTable, one, or, orderBy, out, overlay, param, param, partitionBy, percentRank, percentRank, percentileCont, percentileDisc, pi, position, power, primaryKey, privilege, product, productDistinct, quarter, queries, query, quotedName, rad, rand, rangeBetweenCurrentRow, rangeBetweenFollowing, rangeBetweenPreceding, rangeBetweenUnboundedFollowing, rangeBetweenUnboundedPreceding, rangeCurrentRow, rangeFollowing, rangePreceding, rangeUnboundedFollowing, rangeUnboundedPreceding, rank, rank, ratioToReport, raw, recordType, recordType, recordType, recordType, recordType, recordType, recordType, recordType, recordType, recordType, recordType, recordType, recordType, recordType, recordType, recordType, recordType, recordType, recordType, recordType, recordType, recordType, recordType, regexpReplaceAll, regexpReplaceFirst, regrAvgX, regrAvgY, regrCount, regrIntercept, regrR2, regrSXX, regrSXY, regrSYY, regrSlope, releaseSavepoint, repeat, replace, resultQuery, reverse, revoke, revokeGrantOptionFor, right, role, rollback, rollup, round, row, row, row, row, row, row, row, row, row, row, row, row, row, row, row, row, row, row, row, row, row, row, row, rowField, rowField, rowField, rowField, rowField, rowField, rowField, rowField, rowField, rowField, rowField, rowField, rowField, rowField, rowField, rowField, rowField, rowField, rowField, rowField, rowField, rowField, rowField, rowNumber, rowsBetweenCurrentRow, rowsBetweenFollowing, rowsBetweenPreceding, rowsBetweenUnboundedFollowing, rowsBetweenUnboundedPreceding, rowsCurrentRow, rowsFollowing, rowsFrom, rowsPreceding, rowsUnboundedFollowing, rowsUnboundedPreceding, rpad, rtrim, savepoint, schema, second, select, select, select, select, select, select, select, select, select, select, select, select, select, select, select, select, select, select, select, select, select, select, select, selectCount, selectDistinct, selectDistinct, selectDistinct, selectDistinct, selectDistinct, selectDistinct, selectDistinct, selectDistinct, selectDistinct, selectDistinct, selectDistinct, selectDistinct, selectDistinct, selectDistinct, selectDistinct, selectDistinct, selectDistinct, selectDistinct, selectDistinct, selectDistinct, selectDistinct, selectDistinct, selectDistinct, selectFrom, selectFrom, selectOne, selectZero, sequence, sequence, set, setCatalog, setLocal, setSchema, shl, shr, sign, sin, sinh, space, splitPart, sql, sqrt, square, startTransaction, stddevPop, stddevSamp, substring, substringIndex, sum, sumDistinct, systemName, table, table, table, tan, tanh, tau, time, timestamp, timestampAdd, timestampDiff, timestampDiff, timestampSub, timezone, timezoneHour, timezoneMinute, toChar, toDate, toHex, toLocalDate, toLocalDateTime, toTimestamp, translate, trim, trueCondition, trunc, trunc, trunc, trunc, trunc, truncate, truncate, truncateTable, truncateTable, tryCast, two, type, type, unique, unique, unnest, unquotedName, update, upper, user, using, using, uuid, val, val, val, val, val, val, val, val, val, val, val, val, val, val, val, val, val, val, val, val, val, val, val, val, val, val, val, val, val, value, value, value, value, value, value, value, value, value, value, value, value, value, value, value, value, value, value, value, value, value, value, value, value, value, value, value, value, value, value, values, values, values, values, values, values, values, values, values, values, values, values, values, values, values, values, values, values, values, values, values, values, values, varPop, varSamp, week, when, widthBucket, with, with, with, with, with, with, with, with, with, with, with, with, with, with, with, with, with, with, with, with, with, with, with, with, withRecursive, withRecursive, withRecursive, withRecursive, withRecursive, withRecursive, withRecursive, withRecursive, withRecursive, withRecursive, withRecursive, withRecursive, withRecursive, withRecursive, withRecursive, withRecursive, withRecursive, withRecursive, withRecursive, withRecursive, withRecursive, withRecursive, withRecursive, withRecursive, xmlagg, xmlattributes, xmlcomment, xmlconcat, xmlelement, xmlexists, xmlforest, xmlparseContent, xmlparseDocument, xmlpi, xmlquery, xmlserializeContent, xmlserializeDocument, xmltable, xor, year, zero
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • WingsJooqUtil

        WingsJooqUtil()
    • Method Detail

      • replaceInto

         static RowCountQuery replaceInto(TableRecord<out Object> record)

        CUD listener does not trigger

      • condEqSkip

        @NotNull() static <Z> Condition condEqSkip(Field<Z> filed, Collection<Z> value)

        Return NoCondition if value is null, otherwise return eq(NotNull)

        Parameters:
        filed - field
        value - field value
        Returns:

        Condition

      • condEqSkip

        @NotNull() static <Z> Condition condEqSkip(Field<Z> filed, Collection<Z> value, Predicate<Z> filter)

        Return NoCondition if filter is true, otherwise return eq(NotNull)

        Parameters:
        filed - field
        value - field value
        filter - filter
        Returns:

        Condition

      • condInSkip

        @NotNull() static <Z> Condition condInSkip(Field<Z> filed, Collection<Z> value)

        Return NoCondition if value is null, otherwise return in(NotNull)

        Parameters:
        filed - field
        value - field value
        Returns:

        Condition

      • condInSkip

        @NotNull() static <Z> Condition condInSkip(Field<Z> filed, Collection<Z> value, Predicate<Z> filter)

        Return NoCondition if filter is true, otherwise return in(NotNull)

        Parameters:
        filed - field
        value - field value
        filter - filter
        Returns:

        Condition

      • condRange

        @NotNull() static <Z> Condition condRange(Field<Z> field, Z lowerInclusive, Z upperInclusive)

        Return a between condition

        Parameters:
        field - field
        lowerInclusive - lower (min) value (include)
        upperInclusive - upper (max) value (include)
        Returns:

        Condition

      • condChain

        @NotNull() static Condition condChain(TableRecord<out Object> record)
      • condChain

        @NotNull() static Condition condChain(TableRecord<out Object> record, boolean ignoreNull)
      • condChain

        @NotNull() static Condition condChain(Operator andOr, TableRecord<out Object> record)
      • condChain

        @NotNull() static Condition condChain(Operator andOr, TableRecord<out Object> record, boolean ignoreNull)

        Return a condition join by and/or with the record, e.g. type=1 and name='dog'

        Parameters:
        andOr - operator (and/or)
        record - table record
        ignoreNull - whether to ignore null
        Returns:

        condition

      • condChain

        @NotNull() static Condition condChain(Operator andOr, Map<String, Object> fieldValue, boolean ignoreNull)
      • condChain

        @NotNull() static Condition condChain(Operator andOr, Map<String, Object> fieldValue, boolean ignoreNull, TableImpl<out Object> alias)

        Return a condition join by and/or with the field map use `f.in(v)` if value is collection, otherwise `f.eq(v)`

        Parameters:
        andOr - operator (and/or)
        fieldValue - filed name and value
        ignoreNull - whether to ignore null
        alias - table name or alias
        Returns:

        condition

      • condField

        @Nullable() static Condition condField(Field<out Object> field, boolean ignoreNull, Object value)
        filed is null -> throw
        value is Array | Coolection -> f.in(v)
        null && !ignore -> f.isNull()
        _ -> f.eq(v)
        
        Parameters:
        field - filed
        ignoreNull - filed
        value - value
        Returns:

        condition

      • condField

        @NotNull() static List<Condition> condField(TableRecord<out Object> record, boolean ignoreNull, Array<Field<out Object>> includes)

        Return a condition by record and specified fileds. eg. type=1 and name='dog'

        Parameters:
        record - record
        ignoreNull - whether to ignore null
        includes - included fields, all if empty
        Returns:

        condition