org.jooq.impl
Class Factory

java.lang.Object
  extended by org.jooq.impl.Factory
All Implemented Interfaces:
Serializable, Configuration, FactoryOperations
Direct Known Subclasses:
ASEFactory, CUBRIDFactory, DB2Factory, DerbyFactory, H2Factory, HSQLDBFactory, IngresFactory, MySQLFactory, OracleFactory, PostgresFactory, SQLiteFactory, SQLServerFactory, SybaseFactory

public class Factory
extends Object
implements FactoryOperations

A factory providing implementations to the org.jooq interfaces

This factory is the main entry point for client code, to access jOOQ classes and functionality. Here, you can instanciate all of those objects that cannot be accessed through other objects. For example, to create a Field representing a constant value, you can write:

 Field<String> field = Factory.val("Hello World")
 

Also, some SQL clauses cannot be expressed easily with DSL, for instance the EXISTS clause, as it is not applied on a concrete object (yet). Hence you should write

 Condition condition = Factory.exists(new Factory().select(...));
 

A Factory holds a reference to a JDBC Connection and operates upon that connection. This means, that a Factory is not thread-safe, since a JDBC Connection is not thread-safe either.

Author:
Lukas Eder
See Also:
Serialized Form

Constructor Summary
Factory(Connection connection, SQLDialect dialect)
          Create a factory with connection and dialect configured
Factory(Connection connection, SQLDialect dialect, SchemaMapping mapping)
          Deprecated. - 2.0.5 - Use Factory(Connection, SQLDialect, Settings) instead
Factory(Connection connection, SQLDialect dialect, Settings settings)
          Create a factory with connection, a dialect and a schema mapping configured
 
Method Summary
static
<T extends Number>
Field<T>
abs(Field<T> field)
          Get the absolute value of a numeric field: abs(field) This renders the same on all dialects: abs([field])
static
<T extends Number>
Field<T>
abs(T value)
          Get the absolute value of a numeric field: abs(field)
static Field<BigDecimal> acos(Field<? extends Number> field)
          Get the arc cosine(field) function This renders the acos function where available: acos([field])
static Field<BigDecimal> acos(Number value)
          Get the arc cosine(field) function
static Field<Integer> ascii(Field<String> field)
          Get the ascii(field) function This renders the ascii function: ascii([field])
static Field<Integer> ascii(String field)
          Get the ascii(field) function
static Field<BigDecimal> asin(Field<? extends Number> field)
          Get the arc sine(field) function This renders the asin function where available: asin([field])
static Field<BigDecimal> asin(Number value)
          Get the arc sine(field) function
static Field<BigDecimal> atan(Field<? extends Number> field)
          Get the arc tangent(field) function This renders the atan function where available: atan([field])
static Field<BigDecimal> atan(Number value)
          Get the arc tangent(field) function
static Field<BigDecimal> atan2(Field<? extends Number> x, Field<? extends Number> y)
          Get the atan2(field, y) function This renders the atan2 or atn2 function where available: atan2([x], [y]) or atn2([x], [y])
static Field<BigDecimal> atan2(Field<? extends Number> x, Number y)
          Get the atan2(field, y) function
static Field<BigDecimal> atan2(Number x, Field<? extends Number> y)
          Get the atan2(field, y) function
static Field<BigDecimal> atan2(Number x, Number y)
          Get the atan2(field, y) function
 void attach(Attachable... attachables)
          Attach this Factory to some attachables
 void attach(Collection<Attachable> attachables)
          Attach this Factory to some attachables
static AggregateFunction<BigDecimal> avg(Field<? extends Number> field)
          Get the average over a numeric field: avg(field)
static AggregateFunction<BigDecimal> avgDistinct(Field<? extends Number> field)
          Get the average over a numeric field: avg(distinct field)
 Batch batch(Collection<? extends Query> queries)
          Execute a set of queries in batch mode (without bind values).
 Batch batch(Query... queries)
          Execute a set of queries in batch mode (without bind values).
 BatchBindStep batch(Query query)
          Execute a set of queries in batch mode (with bind values).
 int bind(QueryPart part, PreparedStatement stmt)
          Get a new BindContext for the context of this factory This will return an initialised bind context as such: Context.declareFields() == false Context.declareTables() == false RenderContext for JOOQ INTERNAL USE only.
 BindContext bindContext(PreparedStatement stmt)
          Get a new BindContext for the context of this factory This will return an initialised bind context as such: Context.declareFields() == false Context.declareTables() == false RenderContext for JOOQ INTERNAL USE only.
static
<T extends Number>
Field<T>
bitAnd(Field<T> field1, Field<T> field2)
          The bitwise and operator.
static
<T extends Number>
Field<T>
bitAnd(Field<T> value1, T value2)
          The bitwise and operator.
static
<T extends Number>
Field<T>
bitAnd(T value1, Field<T> value2)
          The bitwise and operator.
static
<T extends Number>
Field<T>
bitAnd(T value1, T value2)
          The bitwise and operator.
static Field<Integer> bitCount(Field<? extends Number> field)
          The MySQL BIT_COUNT(field) function, counting the number of bits that are set in this number.
static Field<Integer> bitCount(Number value)
          The MySQL BIT_COUNT(field) function, counting the number of bits that are set in this number.
static Field<Integer> bitLength(Field<String> field)
          Get the bit_length(field) function This translates into any dialect
static Field<Integer> bitLength(String value)
          Get the bit_length(field) function This translates into any dialect
static
<T extends Number>
Field<T>
bitNand(Field<T> field1, Field<T> field2)
          The bitwise not and operator.
static
<T extends Number>
Field<T>
bitNand(Field<T> value1, T value2)
          The bitwise not and operator.
static
<T extends Number>
Field<T>
bitNand(T value1, Field<T> value2)
          The bitwise not and operator.
static
<T extends Number>
Field<T>
bitNand(T value1, T value2)
          The bitwise not and operator.
static
<T extends Number>
Field<T>
bitNor(Field<T> field1, Field<T> field2)
          The bitwise not or operator.
static
<T extends Number>
Field<T>
bitNor(Field<T> value1, T value2)
          The bitwise not or operator.
static
<T extends Number>
Field<T>
bitNor(T value1, Field<T> value2)
          The bitwise not or operator.
static
<T extends Number>
Field<T>
bitNor(T value1, T value2)
          The bitwise not or operator.
static
<T extends Number>
Field<T>
bitNot(Field<T> field)
          The bitwise not operator.
static
<T extends Number>
Field<T>
bitNot(T value)
          The bitwise not operator.
static
<T extends Number>
Field<T>
bitOr(Field<T> field1, Field<T> field2)
          The bitwise or operator.
static
<T extends Number>
Field<T>
bitOr(Field<T> value1, T value2)
          The bitwise or operator.
static
<T extends Number>
Field<T>
bitOr(T value1, Field<T> value2)
          The bitwise or operator.
static
<T extends Number>
Field<T>
bitOr(T value1, T value2)
          The bitwise or operator.
static
<T extends Number>
Field<T>
bitXNor(Field<T> field1, Field<T> field2)
          The bitwise not xor operator.
static
<T extends Number>
Field<T>
bitXNor(Field<T> value1, T value2)
          The bitwise not xor operator.
static
<T extends Number>
Field<T>
bitXNor(T value1, Field<T> value2)
          The bitwise not xor operator.
static
<T extends Number>
Field<T>
bitXNor(T value1, T value2)
          The bitwise not xor operator.
static
<T extends Number>
Field<T>
bitXor(Field<T> field1, Field<T> field2)
          The bitwise xor operator.
static
<T extends Number>
Field<T>
bitXor(Field<T> value1, T value2)
          The bitwise xor operator.
static
<T extends Number>
Field<T>
bitXor(T value1, Field<T> value2)
          The bitwise xor operator.
static
<T extends Number>
Field<T>
bitXor(T value1, T value2)
          The bitwise xor operator.
static
<T> Field<T>
cast(Object value, Class<? extends T> type)
          Cast a value to another type
static
<T> Field<T>
cast(Object value, DataType<T> type)
          Cast a value to another type
static
<T> Field<T>
cast(Object value, Field<T> as)
          Cast a value to the type of another field.
static
<T> Field<T>
castNull(Class<? extends T> type)
          Cast null to a type
static
<T> Field<T>
castNull(DataType<T> type)
          Cast null to a type
static
<T> Field<T>
castNull(Field<T> as)
          Cast null to the type of another field.
static
<T extends Number>
Field<T>
ceil(Field<T> field)
          Get the smallest integer value not less than [field] This renders the ceil or ceiling function where available: ceil([field]) or ceiling([field]) ... or simulates it elsewhere using round: round([field] + 0.499999999999999)
static
<T extends Number>
Field<T>
ceil(T value)
          Get the smallest integer value not less than [this]
static Field<Integer> charLength(Field<String> field)
          Get the char_length(field) function This translates into any dialect
static Field<Integer> charLength(String value)
          Get the char_length(field) function This translates into any dialect
static
<T> Field<T>
coalesce(Field<T> field, Field<?>... fields)
          Gets the Oracle-style COALESCE(field1, field2, ... , field n) function Returns the dialect's equivalent to COALESCE: Oracle COALESCE
static
<T> Field<T>
coalesce(T value, T... values)
          Gets the Oracle-style COALESCE(value1, value2, ... , value n) function
static Field<String> concat(Field<?>... fields)
          Get the concat(field[, field, ...]) function This creates fields[0] || fields[1] || ...
static Field<String> concat(String... values)
          Get the concat(value[, value, ...]) function
static Condition condition(String sql)
          Create a new condition holding plain SQL.
static Condition condition(String sql, Object... bindings)
          Create a new condition holding plain SQL.
static Field<Boolean> connectByIsCycle()
          Retrieve the Oracle-specific CONNECT_BY_ISCYCLE pseudo-field (to be used along with CONNECT BY clauses)
static Field<Boolean> connectByIsLeaf()
          Retrieve the Oracle-specific CONNECT_BY_ISLEAF pseudo-field (to be used along with CONNECT BY clauses)
static Field<BigDecimal> cos(Field<? extends Number> field)
          Get the cosine(field) function This renders the cos function where available: cos([field])
static Field<BigDecimal> cos(Number value)
          Get the cosine(field) function
static Field<BigDecimal> cosh(Field<? extends Number> field)
          Get the hyperbolic cosine function: cosh(field) This renders the cosh function where available: cosh([field]) ... or simulates it elsewhere using exp: (exp([field] * 2) + 1) / (exp([field] * 2))
static Field<BigDecimal> cosh(Number value)
          Get the hyperbolic cosine function: cosh(field)
static Field<BigDecimal> cot(Field<? extends Number> field)
          Get the cotangent(field) function This renders the cot function where available: cot([field]) ... or simulates it elsewhere using sin and cos: cos([field]) / sin([field])
static Field<BigDecimal> cot(Number value)
          Get the cotangent(field) function
static Field<BigDecimal> coth(Field<? extends Number> field)
          Get the hyperbolic cotangent function: coth(field) This is not supported by any RDBMS, but simulated using exp exp: (exp([field] * 2) + 1) / (exp([field] * 2) - 1)
static Field<BigDecimal> coth(Number value)
          Get the hyperbolic cotangent function: coth(field)
static AggregateFunction<Integer> count()
          Get the count(*) function
static AggregateFunction<Integer> count(Field<?> field)
          Get the count(field) function
static AggregateFunction<Integer> countDistinct(Field<?> field)
          Get the count(distinct field) function
static Field<?> cube(Field<?>... fields)
          Create a CUBE(field1, field2, .., fieldn) grouping field This has been observed to work with the following databases: DB2 Oracle SQL Server Sybase SQL Anywhere Please check the SQL Server documentation for a very nice explanation of CUBE, ROLLUP, and GROUPING SETS clauses in grouping contexts: http://msdn.microsoft.com/en-US/library/bb522495.aspx
static WindowOverStep<BigDecimal> cumeDist()
          The cume_dist() over ([analytic clause]) function.
static Field<Date> currentDate()
          Get the current_date() function This translates into any dialect
static Field<Time> currentTime()
          Get the current_time() function This translates into any dialect
static Field<Timestamp> currentTimestamp()
          Get the current_timestamp() function This translates into any dialect
static Field<String> currentUser()
          Get the current_user() function This translates into any dialect
<T extends Number>
T
currval(Sequence<T> sequence)
          Convenience method to fetch the CURRVAL for a sequence directly from this Factory's underlying JDBC Connection
static Field<Integer> dateDiff(Date date1, Date date2)
          Get the date difference in number of days This translates into any dialect
static Field<Integer> dateDiff(Date date1, Field<Date> date2)
          Get the date difference in number of days This translates into any dialect
static Field<Integer> dateDiff(Field<Date> date1, Date date2)
          Get the date difference in number of days This translates into any dialect
static Field<Integer> dateDiff(Field<Date> date1, Field<Date> date2)
          Get the date difference in number of days This translates into any dialect
static Field<Integer> day(Date value)
          Get the day part of a date This is the same as calling extract(java.util.Date, DatePart) with DatePart.DAY
static Field<Integer> day(Field<? extends Date> field)
          Get the day part of a date This is the same as calling extract(Field, DatePart) with DatePart.DAY
static Case decode()
          Initialise a Case statement.
static
<Z,T> Field<Z>
decode(Field<T> value, Field<T> search, Field<Z> result)
          Gets the Oracle-style DECODE(expression, search, result[, search , result]... [, default]) function
static
<Z,T> Field<Z>
decode(Field<T> value, Field<T> search, Field<Z> result, Field<?>... more)
          Gets the Oracle-style DECODE(expression, search, result[, search , result]... [, default]) function Returns the dialect's equivalent to DECODE: Oracle DECODE Other dialects: CASE WHEN [this = search] THEN [result], [WHEN more...
static
<Z,T> Field<Z>
decode(T value, T search, Z result)
          Gets the Oracle-style DECODE(expression, search, result[, search , result]... [, default]) function
static
<Z,T> Field<Z>
decode(T value, T search, Z result, Object... more)
          Gets the Oracle-style DECODE(expression, search, result[, search , result]... [, default]) function
static Field<BigDecimal> deg(Field<? extends Number> field)
          Calculate degrees from radians from this field This renders the degrees function where available: degrees([field]) ... or simulates it elsewhere: [field] * 180 / PI
static Field<BigDecimal> deg(Number value)
          Calculate degrees from radians from this field
<R extends Record>
DeleteWhereStep<R>
delete(Table<R> table)
          Create a new DSL delete statement.
<R extends Record>
DeleteQuery<R>
deleteQuery(Table<R> table)
          Create a new DeleteQuery
static WindowOverStep<Integer> denseRank()
          The dense_rank() over ([analytic clause]) function.
static Field<BigDecimal> e()
          The E literal (Euler number) This will be any of the following: The underlying RDBMS' E literal or E() function Math.E
static Field<String> escape(Field<String> field, char escape)
          Convenience method for replace(Field, String, String) to escape data for use with Field.like(Field, char) Essentially, this escapes % and _ characters
static String escape(String value, char escape)
          Convenience method for replace(Field, String, String) to escape data for use with Field.like(Field, char) Essentially, this escapes % and _ characters
 int execute(String sql)
          Execute a query holding plain SQL.
 int execute(String sql, Object... bindings)
          Execute a new query holding plain SQL.
<R extends TableRecord<R>>
int
executeDelete(Table<R> table)
          Delete records from a table DELETE FROM [table]
<R extends TableRecord<R>,T>
int
executeDelete(Table<R> table, Condition condition)
          Delete records from a table DELETE FROM [table] WHERE [condition]
<R extends TableRecord<R>>
int
executeDeleteOne(Table<R> table)
          Delete one record in a table DELETE FROM [table]
<R extends TableRecord<R>,T>
int
executeDeleteOne(Table<R> table, Condition condition)
          Delete one record in a table DELETE FROM [table] WHERE [condition]
<R extends TableRecord<R>>
int
executeInsert(Table<R> table, R record)
          Insert one record INSERT INTO [table] ...
<R extends TableRecord<R>>
int
executeUpdate(Table<R> table, R record)
          Update a table UPDATE [table] SET [modified values in record]
<R extends TableRecord<R>,T>
int
executeUpdate(Table<R> table, R record, Condition condition)
          Update a table UPDATE [table] SET [modified values in record] WHERE [condition]
<R extends TableRecord<R>>
int
executeUpdateOne(Table<R> table, R record)
          Update one record in a table UPDATE [table] SET [modified values in record]
<R extends TableRecord<R>,T>
int
executeUpdateOne(Table<R> table, R record, Condition condition)
          Update one record in a table UPDATE [table] SET [modified values in record] WHERE [condition]
static Condition exists(Select<?> query)
          Create an exists condition.
static Field<BigDecimal> exp(Field<? extends Number> field)
          Get the exp(field) function, taking this field as the power of e This renders the same on all dialects: exp([field])
static Field<BigDecimal> exp(Number value)
          Get the exp(field) function, taking this field as the power of e
static Field<Integer> extract(Date value, DatePart datePart)
          Get the extract(field, datePart) function This translates into any dialect
static Field<Integer> extract(Field<? extends Date> field, DatePart datePart)
          Get the extract(field, datePart) function This translates into any dialect
static Condition falseCondition()
          Return a Condition that will always evaluate to false
 Result<Record> fetch(ResultSet rs)
          Fetch all data from a JDBC ResultSet and transform it to a jOOQ Result.
 Result<Record> fetch(String sql)
          Execute a new query holding plain SQL.
 Result<Record> fetch(String sql, Object... bindings)
          Execute a new query holding plain SQL.
<R extends Record>
Result<R>
fetch(Table<R> table)
          Execute and return all records for SELECT * FROM [table]
<R extends Record>
Result<R>
fetch(Table<R> table, Condition condition)
          Execute and return all records for SELECT * FROM [table] WHERE [condition]
<R extends Record>
R
fetchAny(Table<R> table)
          Execute and return zero or one record for SELECT * FROM [table] LIMIT 1
 Cursor<Record> fetchLazy(String sql)
          Execute a new query holding plain SQL and "lazily" return the generated result.
 Cursor<Record> fetchLazy(String sql, Object... bindings)
          Execute a new query holding plain SQL and "lazily" return the generated result.
 List<Result<Record>> fetchMany(String sql)
          Execute a new query holding plain SQL, possibly returning several result sets Example (Sybase ASE): String sql = "sp_help 'my_table'"; NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity.
 List<Result<Record>> fetchMany(String sql, Object... bindings)
          Execute a new query holding plain SQL, possibly returning several result sets.
 Record fetchOne(String sql)
          Execute a new query holding plain SQL.
 Record fetchOne(String sql, Object... bindings)
          Execute a new query holding plain SQL.
<R extends Record>
R
fetchOne(Table<R> table)
          Execute and return zero or one record for SELECT * FROM [table]
<R extends Record>
R
fetchOne(Table<R> table, Condition condition)
          Execute and return zero or one record for SELECT * FROM [table] WHERE [condition]
static Field<Object> field(String sql)
          A PlainSQLField is a field that can contain user-defined plain SQL, because sometimes it is easier to express things directly in SQL, for instance complex proprietary functions.
static
<T> Field<T>
field(String sql, Class<T> type)
          A PlainSQLField is a field that can contain user-defined plain SQL, because sometimes it is easier to express things directly in SQL, for instance complex proprietary functions.
static
<T> Field<T>
field(String sql, Class<T> type, Object... bindings)
          A PlainSQLField is a field that can contain user-defined plain SQL, because sometimes it is easier to express things directly in SQL, for instance complex proprietary functions.
static
<T> Field<T>
field(String sql, Class<T> type, QueryPart... parts)
          A custom SQL clause that can render arbitrary SQL elements.
static
<T> Field<T>
field(String sql, DataType<T> type)
          A PlainSQLField is a field that can contain user-defined plain SQL, because sometimes it is easier to express things directly in SQL, for instance complex proprietary functions.
static
<T> Field<T>
field(String sql, DataType<T> type, Object... bindings)
          A PlainSQLField is a field that can contain user-defined plain SQL, because sometimes it is easier to express things directly in SQL, for instance complex proprietary functions.
static
<T> Field<T>
field(String sql, DataType<T> type, QueryPart... parts)
          A custom SQL clause that can render arbitrary SQL elements.
static Field<Object> field(String sql, Object... bindings)
          A PlainSQLField is a field that can contain user-defined plain SQL, because sometimes it is easier to express things directly in SQL, for instance complex proprietary functions.
static Field<Object> field(String sql, QueryPart... parts)
          A custom SQL clause that can render arbitrary SQL elements.
static
<T> WindowIgnoreNullsStep<T>
firstValue(Field<T> field)
          The first_value(field) over ([analytic clause]) function.
static
<T extends Number>
Field<T>
floor(Field<T> field)
          Get the largest integer value not greater than [this] This renders the floor function where available: floor([this]) ... or simulates it elsewhere using round: round([this] - 0.499999999999999)
static
<T extends Number>
Field<T>
floor(T value)
          Get the largest integer value not greater than [this]
static
<T> Field<T>
function(String name, Class<T> type, Field<?>... arguments)
          function() can be used to access native functions that are not yet or insufficiently supported by jOOQ NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity.
static
<T> Field<T>
function(String name, DataType<T> type, Field<?>... arguments)
          function() can be used to access native functions that are not yet or insufficiently supported by jOOQ NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity.
 Connection getConnection()
          Retrieve the configured connection
 Map<String,Object> getData()
          Get all custom data from this Configuration This is custom data that was previously set to the configuration using Configuration.setData(String, Object).
 Object getData(String key)
          Get some custom data from this Configuration This is custom data that was previously set to the configuration using Configuration.setData(String, Object).
static
<T> DataType<T>
getDataType(Class<? extends T> type)
          Get the default data type for the Factory's underlying SQLDialect and a given Java type.
 SQLDialect getDialect()
          Retrieve the configured dialect
 SchemaMapping getSchemaMapping()
          Deprecated. 
 Settings getSettings()
          Retrieve the runtime configuration settings
static
<T> Field<T>
greatest(Field<T> field, Field<?>... others)
          Find the greatest among all values This function has no equivalent in Adaptive Server, Derby, SQL Server and Sybase SQL Anywhere.
static
<T> Field<T>
greatest(T value, T... values)
          Find the greatest among all values This function has no equivalent in Adaptive Server, Derby, SQL Server and Sybase SQL Anywhere.
static GroupConcatOrderByStep groupConcat(Field<?> field)
          Get the aggregated concatenation for a field.
static GroupConcatOrderByStep groupConcatDistinct(Field<?> field)
          Get the aggregated concatenation for a field.
static Field<Integer> grouping(Field<?> field)
          Create a GROUPING(field) aggregation field to be used along with CUBE, ROLLUP, and GROUPING SETS groupings This has been observed to work with the following databases: DB2 Oracle SQL Server Sybase SQL Anywhere
static Field<Integer> groupingId(Field<?>... fields)
          Create a GROUPING_ID(field1, field2, .., fieldn) aggregation field to be used along with CUBE, ROLLUP, and GROUPING SETS groupings This has been observed to work with the following databases: Oracle SQL Server
static Field<?> groupingSets(Collection<Field<?>>... fieldSets)
          Create a GROUPING SETS((field1a, field1b), (field2a), .., (fieldna, fieldnb)) grouping field This has been observed to work with the following databases: DB2 Oracle SQL Server Sybase SQL Anywhere Please check the SQL Server documentation for a very nice explanation of CUBE, ROLLUP, and GROUPING SETS clauses in grouping contexts: http://msdn.microsoft.com/en-US/library/bb522495.aspx
static Field<?> groupingSets(Field<?>... fields)
          Create a GROUPING SETS(field1, field2, .., fieldn) grouping field where each grouping set only consists of a single field.
static Field<?> groupingSets(Field<?>[]... fieldSets)
          Create a GROUPING SETS((field1a, field1b), (field2a), .., (fieldna, fieldnb)) grouping field This has been observed to work with the following databases: DB2 Oracle SQL Server Sybase SQL Anywhere Please check the SQL Server documentation for a very nice explanation of CUBE, ROLLUP, and GROUPING SETS clauses in grouping contexts: http://msdn.microsoft.com/en-US/library/bb522495.aspx
static Field<Integer> hour(Date value)
          Get the hour part of a date This is the same as calling extract(java.util.Date, DatePart) with DatePart.HOUR
static Field<Integer> hour(Field<? extends Date> field)
          Get the hour part of a date This is the same as calling extract(Field, DatePart) with DatePart.HOUR
<R extends Record>
InsertSetStep<R>
insertInto(Table<R> into)
          Create a new DSL insert statement.
<R extends Record>
InsertValuesStep<R>
insertInto(Table<R> into, Collection<? extends Field<?>> fields)
          Create a new DSL insert statement.
<R extends Record>
InsertValuesStep<R>
insertInto(Table<R> into, Field<?>... fields)
          Create a new DSL insert statement.
<R extends Record>
Insert<R>
insertInto(Table<R> into, Select<?> select)
          Deprecated. 
<R extends Record>
InsertQuery<R>
insertQuery(Table<R> into)
          Create a new InsertQuery
static
<T> WindowIgnoreNullsStep<T>
lag(Field<T> field)
          The lag(field) over ([analytic clause]) function.
static
<T> WindowIgnoreNullsStep<T>
lag(Field<T> field, int offset)
          The lag(field, offset) over ([analytic clause]) function.
static
<T> WindowIgnoreNullsStep<T>
lag(Field<T> field, int offset, Field<T> defaultValue)
          The lag(field, offset, defaultValue) over ([analytic clause]) function.
static
<T> WindowIgnoreNullsStep<T>
lag(Field<T> field, int offset, T defaultValue)
          The lag(field, offset, defaultValue) over ([analytic clause]) function.
 BigInteger lastID()
          Retrieve the last inserted ID.
static
<T> WindowIgnoreNullsStep<T>
lastValue(Field<T> field)
          The last_value(field) over ([analytic clause]) function.
static
<T> WindowIgnoreNullsStep<T>
lead(Field<T> field)
          The lead(field) over ([analytic clause]) function.
static
<T> WindowIgnoreNullsStep<T>
lead(Field<T> field, int offset)
          The lead(field, offset) over ([analytic clause]) function.
static
<T> WindowIgnoreNullsStep<T>
lead(Field<T> field, int offset, Field<T> defaultValue)
          The lead(field, offset, defaultValue) over ([analytic clause]) function.
static
<T> WindowIgnoreNullsStep<T>
lead(Field<T> field, int offset, T defaultValue)
          The lead(field, offset, defaultValue) over ([analytic clause]) function.
static
<T> Field<T>
least(Field<T> field, Field<?>... others)
          Find the least among all values This function has no equivalent in Adaptive Server, Derby, SQL Server and Sybase SQL Anywhere.
static
<T> Field<T>
least(T value, T... values)
          Find the least among all values This function has no equivalent in Adaptive Server, Derby, SQL Server and Sybase SQL Anywhere.
static Field<Integer> length(Field<String> field)
          Get the length of a VARCHAR type.
static Field<Integer> length(String value)
          Get the length of a VARCHAR type.
static Field<Integer> level()
          Retrieve the Oracle-specific LEVEL pseudo-field (to be used along with CONNECT BY clauses)
static OrderedAggregateFunction<String> listAgg(Field<?> field)
          Get the aggregated concatenation for a field.
static OrderedAggregateFunction<String> listAgg(Field<?> field, String separator)
          Get the aggregated concatenation for a field.
static
<T> Field<T>
literal(Object literal, Class<T> type)
          Get a typed Field for a literal.
static
<T> Field<T>
literal(Object literal, DataType<T> type)
          Get a typed Field for a literal.
static
<T> Field<T>
literal(T literal)
          Get a typed Field for a literal.
static Field<BigDecimal> ln(Field<? extends Number> field)
          Get the ln(field) function, taking the natural logarithm of this field This renders the ln or log function where available: ln([field]) or log([field])
static Field<BigDecimal> ln(Number value)
          Get the ln(field) function, taking the natural logarithm of this field
<R extends TableRecord<R>>
LoaderOptionsStep<R>
loadInto(Table<R> table)
          Create a new Loader object to load data from a CSV or XML source
static Field<BigDecimal> log(Field<? extends Number> field, int base)
          Get the log(field, base) function This renders the log function where available: log([field]) ... or simulates it elsewhere (in most RDBMS) using the natural logarithm: ln([field]) / ln([base])
static Field<BigDecimal> log(Number value, int base)
          Get the log(field, base) function
static Field<String> lower(Field<String> value)
          Get the lower(field) function This renders the lower function in all dialects: lower([field])
static Field<String> lower(String value)
          Get the lower(field) function
static Field<String> lpad(Field<String> field, Field<? extends Number> length)
          Get the lpad(field, length) function This renders the lpad function where available: lpad([field], [length]) ... or simulates it elsewhere using concat, repeat, and length, which may be simulated as well, depending on the RDBMS: concat(repeat(' ', [length] - length([field])), [field])
static Field<String> lpad(Field<String> field, Field<? extends Number> length, Field<String> character)
          Get the lpad(field, length, character) function This renders the lpad function where available: lpad([field], [length]) ... or simulates it elsewhere using concat, repeat, and length, which may be simulated as well, depending on the RDBMS: concat(repeat([character], [length] - length([field])), [field])
static Field<String> lpad(Field<String> field, int length)
          Get the lpad(field, length) function
static Field<String> lpad(Field<String> field, int length, char character)
          Get the lpad(field, length, character) function
static Field<String> lpad(Field<String> field, int length, String character)
          Get the lpad(field, length, character) function
static Field<String> ltrim(Field<String> value)
          Get the ltrim(field) function This renders the ltrim function in all dialects: ltrim([field])
static Field<String> ltrim(String value)
          Get the ltrim(field) function
static
<T> AggregateFunction<T>
max(Field<T> field)
          Get the max value over a field: max(field)
static
<T> AggregateFunction<T>
maxDistinct(Field<T> field)
          Get the max value over a field: max(distinct field)
static AggregateFunction<BigDecimal> median(Field<? extends Number> field)
          Get the median over a numeric field: median(field) This is known to be supported in any of these RDBMS: HSQLDB Oracle Sybase SQL Anywhere
<R extends Record>
MergeUsingStep<R>
mergeInto(Table<R> table)
          Create a new DSL merge statement.
static
<T> AggregateFunction<T>
min(Field<T> field)
          Get the min value over a field: min(field)
static
<T> AggregateFunction<T>
minDistinct(Field<T> field)
          Get the min value over a field: min(distinct field)
static Field<Integer> minute(Date value)
          Get the minute part of a date This is the same as calling extract(java.util.Date, DatePart) with DatePart.MINUTE
static Field<Integer> minute(Field<? extends Date> field)
          Get the minute part of a date This is the same as calling extract(Field, DatePart) with DatePart.MINUTE
static Field<Integer> month(Date value)
          Get the month part of a date This is the same as calling extract(java.util.Date, DatePart) with DatePart.MONTH
static Field<Integer> month(Field<? extends Date> field)
          Get the month part of a date This is the same as calling extract(Field, DatePart) with DatePart.MONTH
<R extends TableRecord<R>>
R
newRecord(Table<R> table)
          Create a new Record that can be inserted into the corresponding table.
<R extends TableRecord<R>>
R
newRecord(Table<R> table, Object source)
          Create a new pre-filled Record that can be inserted into the corresponding table.
<R extends UDTRecord<R>>
R
newRecord(UDT<R> type)
          Create a new attached UDTRecord.
<T extends Number>
T
nextval(Sequence<T> sequence)
          Convenience method to fetch the NEXTVAL for a sequence directly from this Factory's underlying JDBC Connection
static Condition notExists(Select<?> query)
          Create a not exists condition.
static WindowOverStep<Integer> ntile(int number)
          The ntile([number]) over ([analytic clause]) function.
static
<T> Field<T>
nullif(Field<T> value, Field<T> other)
          Gets the Oracle-style NULLIF(value, other) function Returns the dialect's equivalent to NULLIF: Oracle NULLIF
static
<T> Field<T>
nullif(Field<T> value, T other)
          Gets the Oracle-style NULLIF(value, other) function
static
<T> Field<T>
nullif(T value, Field<T> other)
          Gets the Oracle-style NULLIF(value, other) function
static
<T> Field<T>
nullif(T value, T other)
          Gets the Oracle-style NULLIF(value, other) function
static
<T> Field<T>
nvl(Field<T> value, Field<T> defaultValue)
          Gets the Oracle-style NVL(value, defaultValue) function Returns the dialect's equivalent to NVL: DB2
static
<T> Field<T>
nvl(Field<T> value, T defaultValue)
          Gets the Oracle-style NVL(value, defaultValue) function
static
<T> Field<T>
nvl(T value, Field<T> defaultValue)
          Gets the Oracle-style NVL(value, defaultValue) function
static
<T> Field<T>
nvl(T value, T defaultValue)
          Gets the Oracle-style NVL(value, defaultValue) function
static
<Z> Field<Z>
nvl2(Field<?> value, Field<Z> valueIfNotNull, Field<Z> valueIfNull)
          Gets the Oracle-style NVL2(value, valueIfNotNull, valueIfNull) function Returns the dialect's equivalent to NVL2: Oracle NVL2 Other dialects: CASE WHEN [value] IS NULL THEN [valueIfNull] ELSE [valueIfNotNull] END
static
<Z> Field<Z>
nvl2(Field<?> value, Field<Z> valueIfNotNull, Z valueIfNull)
          Gets the Oracle-style NVL2(value, valueIfNotNull, valueIfNull) function
static
<Z> Field<Z>
nvl2(Field<?> value, Z valueIfNotNull, Field<Z> valueIfNull)
          Gets the Oracle-style NVL2(value, valueIfNotNull, valueIfNull) function
static
<Z> Field<Z>
nvl2(Field<?> value, Z valueIfNotNull, Z valueIfNull)
          Gets the Oracle-style NVL2(value, valueIfNotNull, valueIfNull) function
static Field<Integer> octetLength(Field<String> field)
          Get the octet_length(field) function This translates into any dialect
static Field<Integer> octetLength(String value)
          Get the octet_length(field) function This translates into any dialect
static Field<Integer> one()
          A 1 literal.
static Param<Object> param(String name)
          Create a named parameter with a generic type (Object / SQLDataType.OTHER) and no initial value.
static
<T> Param<T>
param(String name, Class<? extends T> type)
          Create a named parameter with a defined type and no initial value.
static
<T> Param<T>
param(String name, DataType<T> type)
          Create a named parameter with a defined type and no initial value.
static
<T> Param<T>
param(String name, T value)
          Create a named parameter with an initial value.
static WindowOverStep<BigDecimal> percentRank()
          The precent_rank() over ([analytic clause]) function.
static Field<BigDecimal> pi()
          The PI literal.
static Field<Integer> position(Field<String> in, Field<String> search)
          Get the position(in, search) function This renders the position or any equivalent function: position([search] in [in]) or locate([in], [search]) or locate([search], [in]) or instr([in], [search]) or charindex([search], [in])
static Field<Integer> position(Field<String> in, String search)
          Get the position(in, search) function
static Field<Integer> position(String in, Field<String> search)
          Get the position(in, search) function
static Field<Integer> position(String in, String search)
          Get the position(in, search) function
static Field<BigDecimal> power(Field<? extends Number> field, Field<? extends Number> exponent)
          Get the power(field, exponent) function This renders the power function where available: power([field], [exponent]) ... or simulates it elsewhere using ln and exp: exp(ln([field]) * [exponent])
static Field<BigDecimal> power(Field<? extends Number> field, Number exponent)
          Get the power(field, exponent) function
static Field<BigDecimal> power(Number value, Field<? extends Number> exponent)
          Get the power(field, exponent) function
static Field<BigDecimal> power(Number value, Number exponent)
          Get the power(field, exponent) function
static
<T> Field<T>
prior(Field<T> field)
          Add the Oracle-specific PRIOR unary operator before a field (to be used along with CONNECT BY clauses)
 Query query(String sql)
          Create a new query holding plain SQL.
 Query query(String sql, Object... bindings)
          Create a new query holding plain SQL.
static Field<BigDecimal> rad(Field<? extends Number> field)
          Calculate radians from degrees from this field This renders the degrees function where available: degrees([field]) ... or simulates it elsewhere: [field] * PI / 180
static Field<BigDecimal> rad(Number value)
          Calculate radians from degrees from this field
static Field<BigDecimal> rand()
          Get the rand() function
static WindowOverStep<Integer> rank()
          The rank_over() over ([analytic clause]) function.
 String render(QueryPart part)
          Render a QueryPart in the context of this factory This is the same as calling renderContext().render(part)
 RenderContext renderContext()
          Get a new RenderContext for the context of this factory This will return an initialised render context as such: Context.declareFields() == false Context.declareTables() == false RenderContext.inline() == false RenderContext.namedParams() == false RenderContext for JOOQ INTERNAL USE only.
 String renderInlined(QueryPart part)
          Render a QueryPart in the context of this factory, inlining all bind variables.
 String renderNamedParams(QueryPart part)
          Render a QueryPart in the context of this factory, rendering bind variables as named parameters.
static Field<String> repeat(Field<String> field, Field<? extends Number> count)
          Get the repeat(field, count) function This renders the repeat or replicate function where available: repeat([field], [count]) or replicate([field], [count]) ... or simulates it elsewhere using rpad and length, which may be simulated as well, depending on the RDBMS: rpad([field], length([field]) * [count], [field])
static Field<String> repeat(Field<String> field, int count)
          Get the repeat(count) function
static Field<String> repeat(String field, Field<? extends Number> count)
          Get the repeat(field, count) function
static Field<String> repeat(String field, int count)
          Get the repeat(field, count) function
static Field<String> replace(Field<String> field, Field<String> search)
          Get the replace(field, search) function This renders the replace or str_replace function where available: replace([field], [search]) or str_replace([field], [search]) ... or simulates it elsewhere using the three-argument replace function: replace([field], [search], '')
static Field<String> replace(Field<String> field, Field<String> search, Field<String> replace)
          Get the replace(field, search, replace) function This renders the replace or str_replace function: replace([field], [search]) or str_replace([field], [search])
static Field<String> replace(Field<String> field, String search)
          Get the replace(field, search) function
static Field<String> replace(Field<String> field, String search, String replace)
          Get the replace(field, search, replace) function
 ResultQuery<Record> resultQuery(String sql)
          Create a new query holding plain SQL.
 ResultQuery<Record> resultQuery(String sql, Object... bindings)
          Create a new query holding plain SQL.
static Field<?> rollup(Field<?>... fields)
          Create a ROLLUP(field1, field2, .., fieldn) grouping field This has been observed to work with the following databases: CUBRID (simulated using the GROUP BY ..
static
<T extends Number>
Field<T>
round(Field<T> field)
          Get rounded value of a numeric field: round(field) This renders the round function where available: round([field]) or round([field], 0) ... or simulates it elsewhere using floor and ceil
static
<T extends Number>
Field<T>
round(Field<T> field, int decimals)
          Get rounded value of a numeric field: round(field, decimals) This renders the round function where available: round([field], [decimals]) ... or simulates it elsewhere using floor and ceil
static
<T extends Number>
Field<T>
round(T value)
          Get rounded value of a numeric field: round(field)
static
<T extends Number>
Field<T>
round(T value, int decimals)
          Get rounded value of a numeric field: round(field, decimals)
static WindowOverStep<Integer> rowNumber()
          The row_number() over ([analytic clause]) function.
static Field<String> rpad(Field<String> field, Field<? extends Number> length)
          Get the rpad(field, length) function This renders the rpad function where available: rpad([field], [length]) ... or simulates it elsewhere using concat, repeat, and length, which may be simulated as well, depending on the RDBMS: concat([field], repeat(' ', [length] - length([field])))
static Field<String> rpad(Field<String> field, Field<? extends Number> length, Field<String> character)
          Get the rpad(field, length, character) function This renders the rpad function where available: rpad([field], [length]) ... or simulates it elsewhere using concat, repeat, and length, which may be simulated as well, depending on the RDBMS: concat([field], repeat([character], [length] - length([field])))
static Field<String> rpad(Field<String> field, int length)
          Get the rpad(field, length) function
static Field<String> rpad(Field<String> field, int length, char character)
          Get the rpad(field, length, character) function
static Field<String> rpad(Field<String> field, int length, String character)
          Get the rpad(field, length, character) function
static Field<String> rtrim(Field<String> field)
          Get the rtrim(field) function This renders the rtrim function in all dialects: rtrim([field])
static Field<String> rtrim(String value)
          Get the rtrim(field) function
static Field<Integer> second(Date value)
          Get the second part of a date This is the same as calling extract(java.util.Date, DatePart) with DatePart.SECOND
static Field<Integer> second(Field<? extends Date> field)
          Get the second part of a date This is the same as calling extract(Field, DatePart) with DatePart.SECOND
 SelectSelectStep select(Collection<? extends Field<?>> fields)
          Create a new DSL select statement.
 SelectSelectStep select(Field<?>... fields)
          Create a new DSL select statement.
 SelectSelectStep selectCount()
          Create a new DSL select statement for COUNT(*) Example: Factory create = new Factory(); create.selectCount() .from(table1) .join(table2).on(field1.equal(field2)) .where(field1.greaterThan(100)) .orderBy(field2) .execute();
 SelectSelectStep selectDistinct(Collection<? extends Field<?>> fields)
          Create a new DSL select statement.
 SelectSelectStep selectDistinct(Field<?>... fields)
          Create a new DSL select statement.
<R extends Record>
SimpleSelectWhereStep<R>
selectFrom(Table<R> table)
          Create a new DSL select statement Example: SELECT * FROM [table] WHERE [conditions] ORDER BY [ordering] LIMIT [limit clause]
 SelectSelectStep selectOne()
          Create a new DSL select statement for constant 1 literal Example: Factory create = new Factory(); create.selectOne() .from(table1) .join(table2).on(field1.equal(field2)) .where(field1.greaterThan(100)) .orderBy(field2) .execute();
 SelectQuery selectQuery()
          Create a new SelectQuery
<R extends Record>
SimpleSelectQuery<R>
selectQuery(TableLike<R> table)
          Create a new SelectQuery
 SelectSelectStep selectZero()
          Create a new DSL select statement for constant 0 literal Example: Factory create = new Factory(); create.selectZero() .from(table1) .join(table2).on(field1.equal(field2)) .where(field1.greaterThan(100)) .orderBy(field2) .execute();
 void setConnection(Connection connection)
          Set the configured connection
 Object setData(String key, Object value)
          Set some custom data to this Configuration This is custom data that was previously set to the configuration using Configuration.setData(String, Object).
static
<T extends Number>
Field<T>
shl(Field<T> field1, Field<T> field2)
          The bitwise left shift operator.
static
<T extends Number>
Field<T>
shl(Field<T> value1, T value2)
          The bitwise left shift operator.
static
<T extends Number>
Field<T>
shl(T value1, Field<T> value2)
          The bitwise left shift operator.
static
<T extends Number>
Field<T>
shl(T value1, T value2)
          The bitwise left shift operator.
static
<T extends Number>
Field<T>
shr(Field<T> field1, Field<T> field2)
          The bitwise right shift operator.
static
<T extends Number>
Field<T>
shr(Field<T> value1, T value2)
          The bitwise right shift operator.
static
<T extends Number>
Field<T>
shr(T value1, Field<T> value2)
          The bitwise right shift operator.
static
<T extends Number>
Field<T>
shr(T value1, T value2)
          The bitwise right shift operator.
static Field<Integer> sign(Field<? extends Number> field)
          Get the sign of a numeric field: sign(field) This renders the sign function where available: sign([field]) ... or simulates it elsewhere (without bind variables on values -1, 0, 1): CASE WHEN [this] > 0 THEN 1 WHEN [this] < 0 THEN -1 ELSE 0 END
static Field<Integer> sign(Number value)
          Get the sign of a numeric field: sign(field)
static Field<BigDecimal> sin(Field<? extends Number> field)
          Get the sine(field) function This renders the sin function where available: sin([field])
static Field<BigDecimal> sin(Number value)
          Get the sine(field) function
static Field<BigDecimal> sinh(Field<? extends Number> field)
          Get the hyperbolic sine function: sinh(field) This renders the sinh function where available: sinh([field]) ... or simulates it elsewhere using exp: (exp([field] * 2) - 1) / (exp([field] * 2))
static Field<BigDecimal> sinh(Number value)
          Get the hyperbolic sine function: sinh(field)
static Field<BigDecimal> sqrt(Field<? extends Number> field)
          Get the sqrt(field) function This renders the sqrt function where available: sqrt([field]) ... or simulates it elsewhere using power (which in turn may also be simulated using ln and exp functions): power([field], 0.5)
static Field<BigDecimal> sqrt(Number value)
          Get the sqrt(field) function
static AggregateFunction<BigDecimal> stddevPop(Field<? extends Number> field)
          Get the population standard deviation of a numeric field: stddev_pop(field) This is known to be supported in any of these RDBMS: DB2 H2 HSQLDB Ingres MySQL Oracle Postgres SQL Server (stdev) Sybase ASE Sybase SQL Anywhere
static AggregateFunction<BigDecimal> stddevSamp(Field<? extends Number> field)
          Get the sample standard deviation of a numeric field: stddev_samp(field) This is known to be supported in any of these RDBMS: DB2 H2 HSQLDB Ingres MySQL Oracle Postgres SQL Server (stdev) Sybase ASE Sybase SQL Anywhere
static Field<String> substring(Field<String> field, Field<? extends Number> startingPosition)
          Get the substring(field, startingPosition) function This renders the substr or substring function: substr([field], [startingPosition]) or substring([field], [startingPosition])
static Field<String> substring(Field<String> field, Field<? extends Number> startingPosition, Field<? extends Number> length)
          Get the substring(field, startingPosition, length) function This renders the substr or substring function: substr([field], [startingPosition], [length]) or substring([field], [startingPosition], [length])
static Field<String> substring(Field<String> field, int startingPosition)
          Get the substring(field, startingPosition) function
static Field<String> substring(Field<String> field, int startingPosition, int length)
          Get the substring(field, startingPosition, length) function
static AggregateFunction<BigDecimal> sum(Field<? extends Number> field)
          Get the sum over a numeric field: sum(field)
static AggregateFunction<BigDecimal> sumDistinct(Field<? extends Number> field)
          Get the sum over a numeric field: sum(distinct field)
static Field<String> sysConnectByPath(Field<?> field, String separator)
          Retrieve the Oracle-specific SYS_CONNECT_BY_PATH(field, separator) function (to be used along with CONNECT BY clauses).
static Table<?> table(ArrayRecord<?> array)
          A synonym for unnest(ArrayRecord)
static Table<?> table(Field<?> cursor)
          A synonym for unnest(Field)
static Table<?> table(List<?> list)
          A synonym for unnest(List)
static Table<?> table(Object[] array)
          A synonym for unnest(Object[])
static
<R extends Record>
Table<R>
table(Select<R> select)
          A synonym for TableLike.asTable().
static Table<Record> table(String sql)
          A PlainSQLTable is a table that can contain user-defined plain SQL, because sometimes it is easier to express things directly in SQL, for instance complex, but static subqueries or tables from different schemas.
static Table<Record> table(String sql, Object... bindings)
          A PlainSQLTable is a table that can contain user-defined plain SQL, because sometimes it is easier to express things directly in SQL, for instance complex, but static subqueries or tables from different schemas.
static Field<BigDecimal> tan(Field<? extends Number> field)
          Get the tangent(field) function This renders the tan function where available: tan([field])
static Field<BigDecimal> tan(Number value)
          Get the tangent(field) function
static Field<BigDecimal> tanh(Field<? extends Number> field)
          Get the hyperbolic tangent function: tanh(field) This renders the tanh function where available: tanh([field]) ... or simulates it elsewhere using exp: (exp([field] * 2) - 1) / (exp([field] * 2) + 1)
static Field<BigDecimal> tanh(Number value)
          Get the hyperbolic tangent function: tanh(field)
static Field<DayToSecond> timestampDiff(Field<Timestamp> timestamp1, Field<Timestamp> timestamp2)
          Get the timestamp difference as a INTERVAL DAY TO SECOND type This translates into any dialect
static Field<DayToSecond> timestampDiff(Field<Timestamp> timestamp1, Timestamp timestamp2)
          Get the timestamp difference as a INTERVAL DAY TO SECOND type This translates into any dialect
static Field<DayToSecond> timestampDiff(Timestamp timestamp1, Field<Timestamp> timestamp2)
          Get the timestamp difference as a INTERVAL DAY TO SECOND type This translates into any dialect
static Field<DayToSecond> timestampDiff(Timestamp timestamp1, Timestamp timestamp2)
          Get the timestamp difference as a INTERVAL DAY TO SECOND type This translates into any dialect
 String toString()
           
static Field<String> trim(Field<String> field)
          Get the trim(field) function This renders the trim function where available: trim([field]) ... or simulates it elsewhere using rtrim and ltrim: ltrim(rtrim([field]))
static Field<String> trim(String value)
          Get the trim(field) function
static Condition trueCondition()
          Return a Condition that will always evaluate to true
<R extends TableRecord<R>>
Truncate<R>
truncate(Table<R> table)
          Create a new DSL truncate statement.
static Field<Integer> two()
          A 2 literal.
static Table<?> unnest(ArrayRecord<?> array)
          Create a table from an array of values This wraps the argument array in a TABLE function for Oracle.
static Table<?> unnest(Field<?> cursor)
          Create a table from a field.
static Table<?> unnest(List<?> list)
          Create a table from a list of values This is equivalent to the TABLE function for H2, or the UNNEST function in HSQLDB and Postgres For Oracle, use table(ArrayRecord) instead, as Oracle knows only typed arrays In all other dialects, unnesting of arrays is simulated using several UNION ALL connected subqueries.
static Table<?> unnest(Object[] array)
          Create a table from an array of values This is equivalent to the TABLE function for H2, or the UNNEST function in HSQLDB and Postgres For Oracle, use table(ArrayRecord) instead, as Oracle knows only typed arrays In all other dialects, unnesting of arrays is simulated using several UNION ALL connected subqueries.
<R extends Record>
UpdateSetStep<R>
update(Table<R> table)
          Create a new DSL update statement.
<R extends Record>
UpdateQuery<R>
updateQuery(Table<R> table)
          Create a new UpdateQuery
static Field<String> upper(Field<String> field)
          Get the upper(field) function This renders the upper function in all dialects: upper([field])
static Field<String> upper(String value)
          Get the upper(field) function
 int use(Schema schema)
          Use a schema as the default schema of the underlying connection.
 int use(String schema)
          Use a schema as the default schema of the underlying connection.
static
<T> Field<T>
val(Object value, Class<? extends T> type)
          Get a bind value with an associated type, taken from a field
static
<T> Field<T>
val(Object value, DataType<T> type)
          Get a bind value with an associated type This will try to bind value as type in a PreparedStatement.
static
<T> Field<T>
val(Object value, Field<T> field)
          Get a bind value with an associated type, taken from a field
static
<T> Field<T>
val(T value)
          Get a bind value jOOQ tries to derive the RDBMS DataType from the provided Java type <T>.
static List<Field<?>> vals(Object... values)
          Get a list of bind values and fields
static
<T> Field<T>
value(Object value, Class<? extends T> type)
          A synonym for val(Object) to be used in Scala and Groovy, where val is a reserved keyword.
static
<T> Field<T>
value(Object value, DataType<T> type)
          A synonym for val(Object) to be used in Scala and Groovy, where val is a reserved keyword.
static
<T> Field<T>
value(Object value, Field<T> field)
          A synonym for val(Object) to be used in Scala and Groovy, where val is a reserved keyword.
static
<T> Field<T>
value(T value)
          A synonym for val(Object) to be used in Scala and Groovy, where val is a reserved keyword.
static AggregateFunction<BigDecimal> varPop(Field<? extends Number> field)
          Get the population variance of a numeric field: var_pop(field) This is known to be supported in any of these RDBMS: DB2 H2 HSQLDB Ingres MySQL Oracle Postgres SQL Server (stdev) Sybase ASE Sybase SQL Anywhere
static AggregateFunction<BigDecimal> varSamp(Field<? extends Number> field)
          Get the sample variance of a numeric field: var_samp(field) This is known to be supported in any of these RDBMS: H2 HSQLDB Ingres MySQL Oracle Postgres SQL Server (var) Sybase SQL Anywhere
static Field<Integer> year(Date value)
          Get the year part of a date This is the same as calling extract(java.util.Date, DatePart) with DatePart.YEAR
static Field<Integer> year(Field<? extends Date> field)
          Get the year part of a date This is the same as calling extract(Field, DatePart) with DatePart.YEAR
static Field<Integer> zero()
          A 0 literal.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Factory

public Factory(Connection connection,
               SQLDialect dialect)
Create a factory with connection and dialect configured

Parameters:
connection - The connection to use with objects created from this factory
dialect - The dialect to use with objects created from this factory

Factory

@Deprecated
public Factory(Connection connection,
                          SQLDialect dialect,
                          SchemaMapping mapping)
Deprecated. - 2.0.5 - Use Factory(Connection, SQLDialect, Settings) instead

Create a factory with connection, a dialect and a schema mapping configured

Parameters:
connection - The connection to use with objects created from this factory
dialect - The dialect to use with objects created from this factory
mapping - The schema mapping to use with objects created from this factory

Factory

public Factory(Connection connection,
               SQLDialect dialect,
               Settings settings)
Create a factory with connection, a dialect and a schema mapping configured

Parameters:
connection - The connection to use with objects created from this factory
dialect - The dialect to use with objects created from this factory
settings - The runtime settings to apply to objects created from this factory
Method Detail

getDialect

public final SQLDialect getDialect()
Retrieve the configured dialect

Specified by:
getDialect in interface Configuration

getConnection

public final Connection getConnection()
Retrieve the configured connection

Specified by:
getConnection in interface Configuration

setConnection

public final void setConnection(Connection connection)
Description copied from interface: Configuration
Set the configured connection

Specified by:
setConnection in interface Configuration

getSchemaMapping

@Deprecated
public final SchemaMapping getSchemaMapping()
Deprecated. 

Retrieve the configured schema mapping

Specified by:
getSchemaMapping in interface Configuration

getSettings

public final Settings getSettings()
Retrieve the runtime configuration settings

Specified by:
getSettings in interface Configuration

getData

public final Map<String,Object> getData()
Get all custom data from this Configuration

This is custom data that was previously set to the configuration using Configuration.setData(String, Object). Use custom data if you want to pass data to your custom QueryPart or ExecuteListener objects to be made available at render, bind, execution, fetch time.

See ExecuteListener for more details.

Specified by:
getData in interface Configuration
Returns:
The custom data. This is never null
See Also:
ExecuteListener

getData

public final Object getData(String key)
Get some custom data from this Configuration

This is custom data that was previously set to the configuration using Configuration.setData(String, Object). Use custom data if you want to pass data to your custom QueryPart or ExecuteListener objects to be made available at render, bind, execution, fetch time.

See ExecuteListener for more details.

Specified by:
getData in interface Configuration
Parameters:
key - A key to identify the custom data
Returns:
The custom data or null if no such data is contained in this Configuration
See Also:
ExecuteListener

setData

public final Object setData(String key,
                            Object value)
Set some custom data to this Configuration

This is custom data that was previously set to the configuration using Configuration.setData(String, Object). Use custom data if you want to pass data to your custom QueryPart or ExecuteListener objects to be made available at render, bind, execution, fetch time.

Be sure that your custom data implements Serializable if you want to serialise this Configuration or objects referencing this Configuration, e.g. your Record types.

See ExecuteListener for more details.

Specified by:
setData in interface Configuration
Parameters:
key - A key to identify the custom data
value - The custom data or null to unset the custom data
Returns:
The previously set custom data or null if no data was previously set for the given key
See Also:
ExecuteListener

renderContext

public final RenderContext renderContext()
Get a new RenderContext for the context of this factory

This will return an initialised render context as such:

RenderContext for JOOQ INTERNAL USE only. Avoid referencing it directly


render

public final String render(QueryPart part)
Render a QueryPart in the context of this factory

This is the same as calling renderContext().render(part)

Specified by:
render in interface FactoryOperations
Parameters:
part - The QueryPart to be rendered
Returns:
The rendered SQL

renderNamedParams

public final String renderNamedParams(QueryPart part)
Render a QueryPart in the context of this factory, rendering bind variables as named parameters.

This is the same as calling renderContext().namedParams(true).render(part)

Specified by:
renderNamedParams in interface FactoryOperations
Parameters:
part - The QueryPart to be rendered
Returns:
The rendered SQL

renderInlined

public final String renderInlined(QueryPart part)
Render a QueryPart in the context of this factory, inlining all bind variables.

This is the same as calling renderContext().inline(true).render(part)

Specified by:
renderInlined in interface FactoryOperations
Parameters:
part - The QueryPart to be rendered
Returns:
The rendered SQL

bindContext

public final BindContext bindContext(PreparedStatement stmt)
Get a new BindContext for the context of this factory

This will return an initialised bind context as such:

RenderContext for JOOQ INTERNAL USE only. Avoid referencing it directly


bind

public final int bind(QueryPart part,
                      PreparedStatement stmt)
Get a new BindContext for the context of this factory

This will return an initialised bind context as such:

RenderContext for JOOQ INTERNAL USE only. Avoid referencing it directly


attach

public final void attach(Attachable... attachables)
Attach this Factory to some attachables

Specified by:
attach in interface FactoryOperations

attach

public final void attach(Collection<Attachable> attachables)
Attach this Factory to some attachables

Specified by:
attach in interface FactoryOperations

loadInto

public final <R extends TableRecord<R>> LoaderOptionsStep<R> loadInto(Table<R> table)
Create a new Loader object to load data from a CSV or XML source

Specified by:
loadInto in interface FactoryOperations

table

public static <R extends Record> Table<R> table(Select<R> select)
A synonym for TableLike.asTable(). It might look a bit more fluent like this, to some users

See Also:
TableLike.asTable()

table

public static Table<?> table(List<?> list)
A synonym for unnest(List)

See Also:
unnest(List)

table

public static Table<?> table(Object[] array)
A synonym for unnest(Object[])

See Also:
unnest(Object[])

table

public static Table<?> table(ArrayRecord<?> array)
A synonym for unnest(ArrayRecord)

See Also:
unnest(ArrayRecord)

table

public static Table<?> table(Field<?> cursor)
A synonym for unnest(Field)

See Also:
unnest(Field)

unnest

public static Table<?> unnest(List<?> list)
Create a table from a list of values

This is equivalent to the TABLE function for H2, or the UNNEST function in HSQLDB and Postgres

For Oracle, use table(ArrayRecord) instead, as Oracle knows only typed arrays

In all other dialects, unnesting of arrays is simulated using several UNION ALL connected subqueries.


unnest

public static Table<?> unnest(Object[] array)
Create a table from an array of values

This is equivalent to the TABLE function for H2, or the UNNEST function in HSQLDB and Postgres

For Oracle, use table(ArrayRecord) instead, as Oracle knows only typed arrays

In all other dialects, unnesting of arrays is simulated using several UNION ALL connected subqueries.


unnest

public static Table<?> unnest(ArrayRecord<?> array)
Create a table from an array of values

This wraps the argument array in a TABLE function for Oracle. Currently, only Oracle knows typed arrays


unnest

public static Table<?> unnest(Field<?> cursor)
Create a table from a field. The supplied field can have any of these types:

This functionality has only limited scope when used in H2, as ARRAY types involved with stored functions can only be of type Object[]. Such arrays are converted into VARCHAR arrays by jOOQ.

In all dialects where arrays are not supported, unnesting of arrays is simulated using several UNION ALL connected subqueries.


table

public static Table<Record> table(String sql)
A PlainSQLTable is a table that can contain user-defined plain SQL, because sometimes it is easier to express things directly in SQL, for instance complex, but static subqueries or tables from different schemas.

Example

 String sql = "SELECT * FROM USER_TABLES WHERE OWNER = 'MY_SCHEMA'";
 

The provided SQL must evaluate as a table whose type can be dynamically discovered using JDBC's ResultSetMetaData methods. That way, you can be sure that calling methods, such as FieldProvider.getFields() will list the actual fields returned from your result set.

NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

Parameters:
sql - The SQL
Returns:
A table wrapping the plain SQL

table

public static Table<Record> table(String sql,
                                  Object... bindings)
A PlainSQLTable is a table that can contain user-defined plain SQL, because sometimes it is easier to express things directly in SQL, for instance complex, but static subqueries or tables from different schemas. There must be as many binding variables contained in the SQL, as passed in the bindings parameter

Example

 String sql = "SELECT * FROM USER_TABLES WHERE OWNER = ?";
 Object[] bindings = new Object[] { "MY_SCHEMA" };
 

The provided SQL must evaluate as a table whose type can be dynamically discovered using JDBC's ResultSetMetaData methods. That way, you can be sure that calling methods, such as FieldProvider.getFields() will list the actual fields returned from your result set.

NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

Parameters:
sql - The SQL
Returns:
A table wrapping the plain SQL

field

public static Field<Object> field(String sql,
                                  QueryPart... parts)
A custom SQL clause that can render arbitrary SQL elements.

This is useful for constructing more complex SQL syntax elements wherever Field types are expected. An example for this is MySQL's GROUP_CONCAT aggregate function, which has MySQL-specific keywords that are hard to reflect in jOOQ's DSL:

 GROUP_CONCAT([DISTINCT] expr [,expr ...]
       [ORDER BY {unsigned_integer | col_name | expr}
           [ASC | DESC] [,col_name ...]]
       [SEPARATOR str_val])
       

The above MySQL function can be expressed as such:

 clause("GROUP_CONCAT(DISTINCT {0} ORDER BY {1} ASC DEPARATOR '-')", expr1, expr2);
 

NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

Parameters:
sql - The SQL clause, containing {numbered placeholders} where query parts can be injected
Returns:
A field wrapping the plain SQL

field

public static <T> Field<T> field(String sql,
                                 Class<T> type,
                                 QueryPart... parts)
A custom SQL clause that can render arbitrary SQL elements.

This is useful for constructing more complex SQL syntax elements wherever Field types are expected. An example for this is MySQL's GROUP_CONCAT aggregate function, which has MySQL-specific keywords that are hard to reflect in jOOQ's DSL:

 GROUP_CONCAT([DISTINCT] expr [,expr ...]
       [ORDER BY {unsigned_integer | col_name | expr}
           [ASC | DESC] [,col_name ...]]
       [SEPARATOR str_val])
       

The above MySQL function can be expressed as such:

 clause("GROUP_CONCAT(DISTINCT {0} ORDER BY {1} ASC DEPARATOR '-')", expr1, expr2);
 

NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

Parameters:
sql - The SQL clause, containing {numbered placeholders} where query parts can be injected
type - The field type
Returns:
A field wrapping the plain SQL

field

public static <T> Field<T> field(String sql,
                                 DataType<T> type,
                                 QueryPart... parts)
A custom SQL clause that can render arbitrary SQL elements.

This is useful for constructing more complex SQL syntax elements wherever Field types are expected. An example for this is MySQL's GROUP_CONCAT aggregate function, which has MySQL-specific keywords that are hard to reflect in jOOQ's DSL:

 GROUP_CONCAT([DISTINCT] expr [,expr ...]
       [ORDER BY {unsigned_integer | col_name | expr}
           [ASC | DESC] [,col_name ...]]
       [SEPARATOR str_val])
       

The above MySQL function can be expressed as such:

 clause("GROUP_CONCAT(DISTINCT {0} ORDER BY {1} ASC DEPARATOR '-')", expr1, expr2);
 

NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

Parameters:
sql - The SQL clause, containing {numbered placeholders} where query parts can be injected
type - The field type
Returns:
A field wrapping the plain SQL

field

public static Field<Object> field(String sql)
A PlainSQLField is a field that can contain user-defined plain SQL, because sometimes it is easier to express things directly in SQL, for instance complex proprietary functions. There must not be any binding variables contained in the SQL.

Example:

 String sql = "DECODE(MY_FIELD, 1, 100, 200)";
 

NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

Parameters:
sql - The SQL
Returns:
A field wrapping the plain SQL

field

public static Field<Object> field(String sql,
                                  Object... bindings)
A PlainSQLField is a field that can contain user-defined plain SQL, because sometimes it is easier to express things directly in SQL, for instance complex proprietary functions. There must be as many binding variables contained in the SQL, as passed in the bindings parameter

Example:

 String sql = "DECODE(MY_FIELD, ?, ?, ?)";
 Object[] bindings = new Object[] { 1, 100, 200 };

NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

Parameters:
sql - The SQL
bindings - The bindings for the field
Returns:
A field wrapping the plain SQL

field

public static <T> Field<T> field(String sql,
                                 Class<T> type)
A PlainSQLField is a field that can contain user-defined plain SQL, because sometimes it is easier to express things directly in SQL, for instance complex proprietary functions. There must not be any binding variables contained in the SQL.

Example:

 String sql = "DECODE(MY_FIELD, 1, 100, 200)";
 

NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

Parameters:
sql - The SQL
type - The field type
Returns:
A field wrapping the plain SQL

field

public static <T> Field<T> field(String sql,
                                 Class<T> type,
                                 Object... bindings)
A PlainSQLField is a field that can contain user-defined plain SQL, because sometimes it is easier to express things directly in SQL, for instance complex proprietary functions. There must be as many binding variables contained in the SQL, as passed in the bindings parameter

Example:

 String sql = "DECODE(MY_FIELD, ?, ?, ?)";
 Object[] bindings = new Object[] { 1, 100, 200 };

NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

Parameters:
sql - The SQL
type - The field type
bindings - The bindings for the field
Returns:
A field wrapping the plain SQL

field

public static <T> Field<T> field(String sql,
                                 DataType<T> type)
A PlainSQLField is a field that can contain user-defined plain SQL, because sometimes it is easier to express things directly in SQL, for instance complex proprietary functions. There must not be any binding variables contained in the SQL.

Example:

 String sql = "DECODE(MY_FIELD, 1, 100, 200)";
 

NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

Parameters:
sql - The SQL
type - The field type
Returns:
A field wrapping the plain SQL

field

public static <T> Field<T> field(String sql,
                                 DataType<T> type,
                                 Object... bindings)
A PlainSQLField is a field that can contain user-defined plain SQL, because sometimes it is easier to express things directly in SQL, for instance complex proprietary functions. There must be as many binding variables contained in the SQL, as passed in the bindings parameter

Example:

 String sql = "DECODE(MY_FIELD, ?, ?, ?)";
 Object[] bindings = new Object[] { 1, 100, 200 };

NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

Parameters:
sql - The SQL
type - The field type
bindings - The bindings for the field
Returns:
A field wrapping the plain SQL

function

public static <T> Field<T> function(String name,
                                    Class<T> type,
                                    Field<?>... arguments)
function() can be used to access native functions that are not yet or insufficiently supported by jOOQ

NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!


function

public static <T> Field<T> function(String name,
                                    DataType<T> type,
                                    Field<?>... arguments)
function() can be used to access native functions that are not yet or insufficiently supported by jOOQ

NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!


condition

public static Condition condition(String sql)
Create a new condition holding plain SQL. There must not be any binding variables contained in the SQL

Example:

 String sql = "(X = 1 and Y = 2)";

NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

Parameters:
sql - The SQL
Returns:
A condition wrapping the plain SQL

condition

public static Condition condition(String sql,
                                  Object... bindings)
Create a new condition holding plain SQL. There must be as many binding variables contained in the SQL, as passed in the bindings parameter

Example:

 String sql = "(X = ? and Y = ?)";
 Object[] bindings = new Object[] { 1, 2 };

NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

Parameters:
sql - The SQL
bindings - The bindings
Returns:
A condition wrapping the plain SQL

query

public final Query query(String sql)
Create a new query holding plain SQL. There must not be any binding variables contained in the SQL

Example:

 String sql = "SET SCHEMA 'abc'";

NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

Specified by:
query in interface FactoryOperations
Parameters:
sql - The SQL
Returns:
A query wrapping the plain SQL

query

public final Query query(String sql,
                         Object... bindings)
Create a new query holding plain SQL. There must be as many binding variables contained in the SQL, as passed in the bindings parameter

Example:

 String sql = "SET SCHEMA 'abc'";

NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

Specified by:
query in interface FactoryOperations
Parameters:
sql - The SQL
bindings - The bindings
Returns:
A query wrapping the plain SQL

fetch

public final Result<Record> fetch(String sql)
Execute a new query holding plain SQL.

Example (Postgres):

 String sql = "FETCH ALL IN \"\"";
Example (SQLite):

 String sql = "pragma table_info('my_table')";

NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

Specified by:
fetch in interface FactoryOperations
Parameters:
sql - The SQL
Returns:
The results from the executed query. This is never null, even if the database returns no ResultSet

fetch

public final Result<Record> fetch(String sql,
                                  Object... bindings)
Execute a new query holding plain SQL. There must be as many binding variables contained in the SQL, as passed in the bindings parameter

Example (Postgres):

 String sql = "FETCH ALL IN \"\"";
Example (SQLite):

 String sql = "pragma table_info('my_table')";

NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

Specified by:
fetch in interface FactoryOperations
Parameters:
sql - The SQL
bindings - The bindings
Returns:
The results from the executed query. This is never null, even if the database returns no ResultSet

fetchLazy

public final Cursor<Record> fetchLazy(String sql)
                               throws DataAccessException
Execute a new query holding plain SQL and "lazily" return the generated result.

The returned Cursor holds a reference to the executed PreparedStatement and the associated ResultSet. Data can be fetched (or iterated over) lazily, fetching records from the ResultSet one by one.

Example (Postgres):

 String sql = "FETCH ALL IN \"\"";
Example (SQLite):

 String sql = "pragma table_info('my_table')";

NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

Specified by:
fetchLazy in interface FactoryOperations
Parameters:
sql - The SQL
Returns:
The results from the executed query. This is never null, even if the database returns no ResultSet
Throws:
DataAccessException - if something went wrong executing the query

fetchLazy

public final Cursor<Record> fetchLazy(String sql,
                                      Object... bindings)
                               throws DataAccessException
Execute a new query holding plain SQL and "lazily" return the generated result. There must be as many binding variables contained in the SQL, as passed in the bindings parameter

The returned Cursor holds a reference to the executed PreparedStatement and the associated ResultSet. Data can be fetched (or iterated over) lazily, fetching records from the ResultSet one by one.

Example (Postgres):

 String sql = "FETCH ALL IN \"\"";
Example (SQLite):

 String sql = "pragma table_info('my_table')";

NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

Specified by:
fetchLazy in interface FactoryOperations
Parameters:
sql - The SQL
bindings - The bindings
Returns:
The results from the executed query. This is never null, even if the database returns no ResultSet
Throws:
DataAccessException - if something went wrong executing the query

fetchMany

public final List<Result<Record>> fetchMany(String sql)
Execute a new query holding plain SQL, possibly returning several result sets

Example (Sybase ASE):

 String sql = "sp_help 'my_table'";

NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

Specified by:
fetchMany in interface FactoryOperations
Parameters:
sql - The SQL
Returns:
The results from the executed query. This is never null, even if the database returns no ResultSet

fetchMany

public final List<Result<Record>> fetchMany(String sql,
                                            Object... bindings)
Execute a new query holding plain SQL, possibly returning several result sets. There must be as many binding variables contained in the SQL, as passed in the bindings parameter

Example (Sybase ASE):

 String sql = "sp_help 'my_table'";

NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

Specified by:
fetchMany in interface FactoryOperations
Parameters:
sql - The SQL
bindings - The bindings
Returns:
The results from the executed query. This is never null, even if the database returns no ResultSet

fetchOne

public final Record fetchOne(String sql)
Execute a new query holding plain SQL.

Example (Postgres):

 String sql = "FETCH ALL IN \"\"";
Example (SQLite):

 String sql = "pragma table_info('my_table')";

NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

Specified by:
fetchOne in interface FactoryOperations
Parameters:
sql - The SQL
Returns:
The results from the executed query. This is never null, even if the database returns no ResultSet

fetchOne

public final Record fetchOne(String sql,
                             Object... bindings)
Execute a new query holding plain SQL. There must be as many binding variables contained in the SQL, as passed in the bindings parameter

Example (Postgres):

 String sql = "FETCH ALL IN \"\"";
Example (SQLite):

 String sql = "pragma table_info('my_table')";

NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

Specified by:
fetchOne in interface FactoryOperations
Parameters:
sql - The SQL
bindings - The bindings
Returns:
The results from the executed query. This is never null, even if the database returns no ResultSet

execute

public final int execute(String sql)
                  throws DataAccessException
Execute a query holding plain SQL.

NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

Specified by:
execute in interface FactoryOperations
Parameters:
sql - The SQL
Returns:
The results from the executed query
Throws:
DataAccessException - if something went wrong executing the query

execute

public final int execute(String sql,
                         Object... bindings)
                  throws DataAccessException
Execute a new query holding plain SQL. There must be as many binding variables contained in the SQL, as passed in the bindings parameter

NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

Specified by:
execute in interface FactoryOperations
Parameters:
sql - The SQL
bindings - The bindings
Returns:
The results from the executed query
Throws:
DataAccessException - if something went wrong executing the query

resultQuery

public final ResultQuery<Record> resultQuery(String sql)
                                      throws DataAccessException
Create a new query holding plain SQL. There must not be any binding variables contained in the SQL

Use this method, when you want to take advantage of the many ways to fetch results in jOOQ, using ResultQuery. Some examples:

ResultQuery.fetchLazy() Open a cursor and fetch records one by one
ResultQuery.fetchInto(Class) Fetch records into a custom POJO (optionally annotated with JPA annotations)
ResultQuery.fetchInto(RecordHandler) Fetch records into a custom callback (similar to Spring's RowMapper)
ResultQuery.fetchLater() Fetch records of a long-running query asynchronously

Example (Postgres):

 String sql = "FETCH ALL IN \"\"";
Example (SQLite):

 String sql = "pragma table_info('my_table')";

NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

Specified by:
resultQuery in interface FactoryOperations
Parameters:
sql - The SQL
Returns:
An executable query
Throws:
DataAccessException - if something went wrong executing the query

resultQuery

public final ResultQuery<Record> resultQuery(String sql,
                                             Object... bindings)
                                      throws DataAccessException
Create a new query holding plain SQL. There must be as many binding variables contained in the SQL, as passed in the bindings parameter

Use this method, when you want to take advantage of the many ways to fetch results in jOOQ, using ResultQuery. Some examples:

ResultQuery.fetchLazy() Open a cursor and fetch records one by one
ResultQuery.fetchInto(Class) Fetch records into a custom POJO (optionally annotated with JPA annotations)
ResultQuery.fetchInto(RecordHandler) Fetch records into a custom callback (similar to Spring's RowMapper)
ResultQuery.fetchLater() Fetch records of a long-running query asynchronously

Example (Postgres):

 String sql = "FETCH ALL IN \"\"";
Example (SQLite):

 String sql = "pragma table_info('my_table')";

NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

Specified by:
resultQuery in interface FactoryOperations
Parameters:
sql - The SQL
bindings - The bindings
Returns:
An executable query
Throws:
DataAccessException - if something went wrong executing the query

fetch

public final Result<Record> fetch(ResultSet rs)
Fetch all data from a JDBC ResultSet and transform it to a jOOQ Result. After fetching all data, the JDBC ResultSet will be closed.

Specified by:
fetch in interface FactoryOperations
Parameters:
rs - The JDBC ResultSet to fetch data from
Returns:
The resulting jOOQ Result

trueCondition

public static Condition trueCondition()
Return a Condition that will always evaluate to true


falseCondition

public static Condition falseCondition()
Return a Condition that will always evaluate to false


exists

public static Condition exists(Select<?> query)
Create an exists condition.

EXISTS ([query])


notExists

public static Condition notExists(Select<?> query)
Create a not exists condition.

NOT EXISTS ([query])


selectFrom

public final <R extends Record> SimpleSelectWhereStep<R> selectFrom(Table<R> table)
Create a new DSL select statement

Example:

 SELECT * FROM [table] WHERE [conditions] ORDER BY [ordering] LIMIT [limit clause]
 

Specified by:
selectFrom in interface FactoryOperations

select

public final SelectSelectStep select(Field<?>... fields)
Create a new DSL select statement.

Example:

 Factory create = new Factory();

 create.select(field1, field2)
       .from(table1)
       .join(table2).on(field1.equal(field2))
       .where(field1.greaterThan(100))
       .orderBy(field2)
       .execute();
 

Specified by:
select in interface FactoryOperations

selectZero

public final SelectSelectStep selectZero()
Create a new DSL select statement for constant 0 literal

Example:

 Factory create = new Factory();

 create.selectZero()
       .from(table1)
       .join(table2).on(field1.equal(field2))
       .where(field1.greaterThan(100))
       .orderBy(field2)
       .execute();
 

Specified by:
selectZero in interface FactoryOperations
See Also:
zero()

selectOne

public final SelectSelectStep selectOne()
Create a new DSL select statement for constant 1 literal

Example:

 Factory create = new Factory();

 create.selectOne()
       .from(table1)
       .join(table2).on(field1.equal(field2))
       .where(field1.greaterThan(100))
       .orderBy(field2)
       .execute();
 

Specified by:
selectOne in interface FactoryOperations
See Also:
one()

selectCount

public final SelectSelectStep selectCount()
Create a new DSL select statement for COUNT(*)

Example:

 Factory create = new Factory();

 create.selectCount()
       .from(table1)
       .join(table2).on(field1.equal(field2))
       .where(field1.greaterThan(100))
       .orderBy(field2)
       .execute();
 

Specified by:
selectCount in interface FactoryOperations

selectDistinct

public final SelectSelectStep selectDistinct(Field<?>... fields)
Create a new DSL select statement.

Example:

 Factory create = new Factory();

 create.selectDistinct(field1, field2)
       .from(table1)
       .join(table2).on(field1.equal(field2))
       .where(field1.greaterThan(100))
       .orderBy(field2);
 

Specified by:
selectDistinct in interface FactoryOperations

select

public final SelectSelectStep select(Collection<? extends Field<?>> fields)
Create a new DSL select statement.

Example:

 Factory create = new Factory();

 create.select(fields)
       .from(table1)
       .join(table2).on(field1.equal(field2))
       .where(field1.greaterThan(100))
       .orderBy(field2);
 

Specified by:
select in interface FactoryOperations

selectDistinct

public final SelectSelectStep selectDistinct(Collection<? extends Field<?>> fields)
Create a new DSL select statement.

Example:

 Factory create = new Factory();

 create.selectDistinct(fields)
       .from(table1)
       .join(table2).on(field1.equal(field2))
       .where(field1.greaterThan(100))
       .orderBy(field2);
 

Specified by:
selectDistinct in interface FactoryOperations

selectQuery

public final SelectQuery selectQuery()
Create a new SelectQuery

Specified by:
selectQuery in interface FactoryOperations

selectQuery

public final <R extends Record> SimpleSelectQuery<R> selectQuery(TableLike<R> table)
Create a new SelectQuery

Specified by:
selectQuery in interface FactoryOperations
Parameters:
table - The table to select data from
Returns:
The new SelectQuery

insertQuery

public final <R extends Record> InsertQuery<R> insertQuery(Table<R> into)
Create a new InsertQuery

Specified by:
insertQuery in interface FactoryOperations
Parameters:
into - The table to insert data into
Returns:
The new InsertQuery

insertInto

public final <R extends Record> InsertSetStep<R> insertInto(Table<R> into)
Create a new DSL insert statement. This type of insert may feel more convenient to some users, as it uses the UPDATE statement's SET a = b syntax.

Example:

 Factory create = new Factory();

 create.insertInto(table)
       .set(field1, value1)
       .set(field2, value2)
       .newRecord()
       .set(field1, value3)
       .set(field2, value4)
       .onDuplicateKeyUpdate()
       .set(field1, value1)
       .set(field2, value2)
       .execute();
 

Specified by:
insertInto in interface FactoryOperations

insertInto

public final <R extends Record> InsertValuesStep<R> insertInto(Table<R> into,
                                                               Field<?>... fields)
Create a new DSL insert statement.

Example:

 Factory create = new Factory();

 create.insertInto(table, field1, field2)
       .values(value1, value2)
       .values(value3, value4)
       .onDuplicateKeyUpdate()
       .set(field1, value1)
       .set(field2, value2)
       .execute();
 

Specified by:
insertInto in interface FactoryOperations

insertInto

public final <R extends Record> InsertValuesStep<R> insertInto(Table<R> into,
                                                               Collection<? extends Field<?>> fields)
Create a new DSL insert statement.

Example:

 Factory create = new Factory();

 create.insertInto(table, field1, field2)
       .values(value1, value2)
       .values(value3, value4)
       .onDuplicateKeyUpdate()
       .set(field1, value1)
       .set(field2, value2)
       .execute();
 

Specified by:
insertInto in interface FactoryOperations

insertInto

@Deprecated
public final <R extends Record> Insert<R> insertInto(Table<R> into,
                                                                Select<?> select)
Deprecated. 

Create a new DSL insert statement.

Example:

 Factory create = new Factory();

 create.insertInto(table, create.select(1))
       .execute();
 

Specified by:
insertInto in interface FactoryOperations

updateQuery

public final <R extends Record> UpdateQuery<R> updateQuery(Table<R> table)
Create a new UpdateQuery

Specified by:
updateQuery in interface FactoryOperations
Parameters:
table - The table to update data into
Returns:
The new UpdateQuery

update

public final <R extends Record> UpdateSetStep<R> update(Table<R> table)
Create a new DSL update statement.

Example:

 Factory create = new Factory();

 create.update(table)
       .set(field1, value1)
       .set(field2, value2)
       .where(field1.greaterThan(100))
       .execute();
 

Specified by:
update in interface FactoryOperations

mergeInto

public final <R extends Record> MergeUsingStep<R> mergeInto(Table<R> table)
Create a new DSL merge statement.

This statement is available from DSL syntax only. It is known to be supported in some way by any of these dialects:

dialect support type documentation
DB2 SQL:2008 standard and major enhancements http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com. ibm.db2.udb.admin.doc/doc/r0010873.htm
HSQLDB SQL:2008 standard http://hsqldb.org/doc/2.0/guide/dataaccess-chapt.html#N129BA
Oracle SQL:2008 standard and minor enhancements http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/ statements_9016.htm
SQL Server Similar to SQL:2008 standard with some major enhancements http://msdn.microsoft.com/de-de/library/bb510625.aspx
Sybase Similar to SQL:2008 standard with some major enhancements http://dcx.sybase.com/1100/en/dbreference_en11/merge-statement.html

Example:

 Factory create = new Factory();

 create.mergeInto(table)
       .using(select)
       .on(condition)
       .whenMatchedThenUpdate()
       .set(field1, value1)
       .set(field2, value2)
       .whenNotMatchedThenInsert(field1, field2)
       .values(value1, value2)
       .execute();
 

Specified by:
mergeInto in interface FactoryOperations

deleteQuery

public final <R extends Record> DeleteQuery<R> deleteQuery(Table<R> table)
Create a new DeleteQuery

Specified by:
deleteQuery in interface FactoryOperations
Parameters:
table - The table to delete data from
Returns:
The new DeleteQuery

delete

public final <R extends Record> DeleteWhereStep<R> delete(Table<R> table)
Create a new DSL delete statement.

Example:

 Factory create = new Factory();

 create.delete(table)
       .where(field1.greaterThan(100))
       .execute();
 

Specified by:
delete in interface FactoryOperations

batch

public final Batch batch(Query... queries)
Execute a set of queries in batch mode (without bind values).

This essentially runs the following logic:

 Statement s = connection.createStatement();

 for (Query query : queries) {
     s.addBatch(query.getSQL(true));
 }

 s.execute();
 

Specified by:
batch in interface FactoryOperations
See Also:
Statement.executeBatch()

batch

public final Batch batch(Collection<? extends Query> queries)
Execute a set of queries in batch mode (without bind values).

This essentially runs the following logic:

 Statement s = connection.createStatement();

 for (Query query : queries) {
     s.addBatch(query.getSQL(true));
 }

 s.execute();
 

Specified by:
batch in interface FactoryOperations
See Also:
Statement.executeBatch()

batch

public final BatchBindStep batch(Query query)
Execute a set of queries in batch mode (with bind values).

When running

 create.batch(query)
       .bind(valueA1, valueA2)
       .bind(valueB1, valueB2)
       .execute();
 

This essentially runs the following logic:

 Statement s = connection.prepareStatement(query.getSQL(false));

 for (Object[] bindValues : allBindValues) {
     for (Object bindValue : bindValues) {
         s.setXXX(bindValue);
     }

     s.addBatch();
 }

 s.execute();
 

Specified by:
batch in interface FactoryOperations
See Also:
Statement.executeBatch()

truncate

public final <R extends TableRecord<R>> Truncate<R> truncate(Table<R> table)
Create a new DSL truncate statement.

Example:

 Factory create = new Factory();

 create.truncate(table)
       .execute();
 

Most dialects implement the TRUNCATE statement. If it is not supported, it is simulated using an equivalent DELETE statement. This is particularly true for these dialects:

Note, this statement is only supported in DSL mode. Immediate execution is omitted for future extensibility of this command.

Specified by:
truncate in interface FactoryOperations

lastID

public final BigInteger lastID()
Retrieve the last inserted ID.

Note, there are some restrictions to the following dialects:

Specified by:
lastID in interface FactoryOperations
Returns:
The last inserted ID. This may be null in some dialects, if no such number is available.

nextval

public final <T extends Number> T nextval(Sequence<T> sequence)
Convenience method to fetch the NEXTVAL for a sequence directly from this Factory's underlying JDBC Connection

Specified by:
nextval in interface FactoryOperations

currval

public final <T extends Number> T currval(Sequence<T> sequence)
Convenience method to fetch the CURRVAL for a sequence directly from this Factory's underlying JDBC Connection

Specified by:
currval in interface FactoryOperations

use

public final int use(Schema schema)
Use a schema as the default schema of the underlying connection.

This has two effects.

  1. The USE [schema] statement is executed on those RDBMS that support this
  2. The supplied Schema is used as the default schema resulting in omitting that schema in rendered SQL.

The USE [schema] statement translates to the various dialects as follows:

Dialect Command
DB2 SET SCHEMA [schema]
Derby: SET SCHEMA [schema]
H2: SET SCHEMA [schema]
HSQLDB: SET SCHEMA [schema]
MySQL: USE [schema]
Oracle: ALTER SESSION SET CURRENT_SCHEMA = [schema]
Postgres: SET SEARCH_PATH = [schema]
Sybase: USE [schema]

Specified by:
use in interface FactoryOperations

use

public final int use(String schema)
Use a schema as the default schema of the underlying connection.

Specified by:
use in interface FactoryOperations
See Also:
FactoryOperations.use(Schema)

newRecord

public final <R extends UDTRecord<R>> R newRecord(UDT<R> type)
Create a new attached UDTRecord.

Specified by:
newRecord in interface FactoryOperations
Type Parameters:
R - The generic record type
Parameters:
type - The UDT describing records of type <R>
Returns:
The new record

newRecord

public final <R extends TableRecord<R>> R newRecord(Table<R> table)
Create a new Record that can be inserted into the corresponding table.

Specified by:
newRecord in interface FactoryOperations
Type Parameters:
R - The generic record type
Parameters:
table - The table holding records of type <R>
Returns:
The new record

newRecord

public final <R extends TableRecord<R>> R newRecord(Table<R> table,
                                                    Object source)
Create a new pre-filled Record that can be inserted into the corresponding table.

This performs roughly the inverse operation of Record.into(Class)

Specified by:
newRecord in interface FactoryOperations
Type Parameters:
R - The generic record type
Parameters:
table - The table holding records of type <R>
source - The source to be used to fill the new record
Returns:
The new record
See Also:
Record.from(Object), Record.into(Class)

decode

public static Case decode()
Initialise a Case statement. Decode is used as a method name to avoid name clashes with Java's reserved literal "case"

See Also:
Case

decode

public static <Z,T> Field<Z> decode(T value,
                                    T search,
                                    Z result)
Gets the Oracle-style DECODE(expression, search, result[, search , result]... [, default]) function

See Also:
decode(Field, Field, Field, Field[])

decode

public static <Z,T> Field<Z> decode(T value,
                                    T search,
                                    Z result,
                                    Object... more)
Gets the Oracle-style DECODE(expression, search, result[, search , result]... [, default]) function

See Also:
decode(Field, Field, Field, Field[])

decode

public static <Z,T> Field<Z> decode(Field<T> value,
                                    Field<T> search,
                                    Field<Z> result)
Gets the Oracle-style DECODE(expression, search, result[, search , result]... [, default]) function

See Also:
decode(Field, Field, Field, Field[])

decode

public static <Z,T> Field<Z> decode(Field<T> value,
                                    Field<T> search,
                                    Field<Z> result,
                                    Field<?>... more)
Gets the Oracle-style DECODE(expression, search, result[, search , result]... [, default]) function

Returns the dialect's equivalent to DECODE:

Other dialects:

 CASE WHEN [this = search] THEN [result],
     [WHEN more...         THEN more...]
     [ELSE more...]
 END
 

Parameters:
value - The value to decode
search - the mandatory first search parameter
result - the mandatory first result candidate parameter
more - the optional parameters. If more.length is even, then it is assumed that it contains more search/result pairs. If more.length is odd, then it is assumed that it contains more search/result pairs plus a default at the end. *

cast

public static <T> Field<T> cast(Object value,
                                Field<T> as)
Cast a value to the type of another field.

Type Parameters:
T - The generic type of the cast field
Parameters:
value - The value to cast
as - The field whose type is used for the cast
Returns:
The cast field

castNull

public static <T> Field<T> castNull(Field<T> as)
Cast null to the type of another field.

Type Parameters:
T - The generic type of the cast field
Parameters:
as - The field whose type is used for the cast
Returns:
The cast field

cast

public static <T> Field<T> cast(Object value,
                                Class<? extends T> type)
Cast a value to another type

Type Parameters:
T - The generic type of the cast field
Parameters:
value - The value to cast
type - The type that is used for the cast
Returns:
The cast field

castNull

public static <T> Field<T> castNull(DataType<T> type)
Cast null to a type

Type Parameters:
T - The generic type of the cast field
Parameters:
type - The type that is used for the cast
Returns:
The cast field

cast

public static <T> Field<T> cast(Object value,
                                DataType<T> type)
Cast a value to another type

Type Parameters:
T - The generic type of the cast field
Parameters:
value - The value to cast
type - The type that is used for the cast
Returns:
The cast field

castNull

public static <T> Field<T> castNull(Class<? extends T> type)
Cast null to a type

Type Parameters:
T - The generic type of the cast field
Parameters:
type - The type that is used for the cast
Returns:
The cast field

coalesce

public static <T> Field<T> coalesce(T value,
                                    T... values)
Gets the Oracle-style COALESCE(value1, value2, ... , value n) function

See Also:
coalesce(Field, Field...)

coalesce

public static <T> Field<T> coalesce(Field<T> field,
                                    Field<?>... fields)
Gets the Oracle-style COALESCE(field1, field2, ... , field n) function

Returns the dialect's equivalent to COALESCE:


nvl

public static <T> Field<T> nvl(T value,
                               T defaultValue)
Gets the Oracle-style NVL(value, defaultValue) function

See Also:
nvl(Field, Field)

nvl

public static <T> Field<T> nvl(T value,
                               Field<T> defaultValue)
Gets the Oracle-style NVL(value, defaultValue) function

See Also:
nvl(Field, Field)

nvl

public static <T> Field<T> nvl(Field<T> value,
                               T defaultValue)
Gets the Oracle-style NVL(value, defaultValue) function

See Also:
nvl(Field, Field)

nvl

public static <T> Field<T> nvl(Field<T> value,
                               Field<T> defaultValue)
Gets the Oracle-style NVL(value, defaultValue) function

Returns the dialect's equivalent to NVL:


nvl2

public static <Z> Field<Z> nvl2(Field<?> value,
                                Z valueIfNotNull,
                                Z valueIfNull)
Gets the Oracle-style NVL2(value, valueIfNotNull, valueIfNull) function

See Also:
nvl2(Field, Field, Field)

nvl2

public static <Z> Field<Z> nvl2(Field<?> value,
                                Z valueIfNotNull,
                                Field<Z> valueIfNull)
Gets the Oracle-style NVL2(value, valueIfNotNull, valueIfNull) function

See Also:
nvl2(Field, Field, Field)

nvl2

public static <Z> Field<Z> nvl2(Field<?> value,
                                Field<Z> valueIfNotNull,
                                Z valueIfNull)
Gets the Oracle-style NVL2(value, valueIfNotNull, valueIfNull) function

See Also:
nvl2(Field, Field, Field)

nvl2

public static <Z> Field<Z> nvl2(Field<?> value,
                                Field<Z> valueIfNotNull,
                                Field<Z> valueIfNull)
Gets the Oracle-style NVL2(value, valueIfNotNull, valueIfNull) function

Returns the dialect's equivalent to NVL2:

Other dialects: CASE WHEN [value] IS NULL THEN [valueIfNull] ELSE [valueIfNotNull] END


nullif

public static <T> Field<T> nullif(T value,
                                  T other)
Gets the Oracle-style NULLIF(value, other) function

See Also:
nullif(Field, Field)

nullif

public static <T> Field<T> nullif(T value,
                                  Field<T> other)
Gets the Oracle-style NULLIF(value, other) function

See Also:
nullif(Field, Field)

nullif

public static <T> Field<T> nullif(Field<T> value,
                                  T other)
Gets the Oracle-style NULLIF(value, other) function

See Also:
nullif(Field, Field)

nullif

public static <T> Field<T> nullif(Field<T> value,
                                  Field<T> other)
Gets the Oracle-style NULLIF(value, other) function

Returns the dialect's equivalent to NULLIF:


upper

public static Field<String> upper(String value)
Get the upper(field) function

See Also:
upper(Field)

upper

public static Field<String> upper(Field<String> field)
Get the upper(field) function

This renders the upper function in all dialects:

upper([field])


lower

public static Field<String> lower(String value)
Get the lower(field) function

See Also:
lower(Field)

lower

public static Field<String> lower(Field<String> value)
Get the lower(field) function

This renders the lower function in all dialects:

lower([field])


trim

public static Field<String> trim(String value)
Get the trim(field) function

See Also:
trim(Field)

trim

public static Field<String> trim(Field<String> field)
Get the trim(field) function

This renders the trim function where available:

trim([field])
... or simulates it elsewhere using rtrim and ltrim:
ltrim(rtrim([field]))


rtrim

public static Field<String> rtrim(String value)
Get the rtrim(field) function

See Also:
rtrim(Field)

rtrim

public static Field<String> rtrim(Field<String> field)
Get the rtrim(field) function

This renders the rtrim function in all dialects:

rtrim([field])


ltrim

public static Field<String> ltrim(String value)
Get the ltrim(field) function

See Also:
ltrim(Field)

ltrim

public static Field<String> ltrim(Field<String> value)
Get the ltrim(field) function

This renders the ltrim function in all dialects:

ltrim([field])


rpad

public static Field<String> rpad(Field<String> field,
                                 int length)
Get the rpad(field, length) function

See Also:
rpad(Field, Field)

rpad

public static Field<String> rpad(Field<String> field,
                                 Field<? extends Number> length)
Get the rpad(field, length) function

This renders the rpad function where available:

rpad([field], [length])
... or simulates it elsewhere using concat, repeat, and length, which may be simulated as well, depending on the RDBMS:
concat([field], repeat(' ', [length] - length([field])))


rpad

public static Field<String> rpad(Field<String> field,
                                 int length,
                                 char character)
Get the rpad(field, length, character) function

See Also:
rpad(Field, Field, Field)

rpad

public static Field<String> rpad(Field<String> field,
                                 int length,
                                 String character)
Get the rpad(field, length, character) function

See Also:
rpad(Field, Field, Field)

rpad

public static Field<String> rpad(Field<String> field,
                                 Field<? extends Number> length,
                                 Field<String> character)
Get the rpad(field, length, character) function

This renders the rpad function where available:

rpad([field], [length])
... or simulates it elsewhere using concat, repeat, and length, which may be simulated as well, depending on the RDBMS:
concat([field], repeat([character], [length] - length([field])))


lpad

public static Field<String> lpad(Field<String> field,
                                 int length)
Get the lpad(field, length) function

See Also:
lpad(Field, Field)

lpad

public static Field<String> lpad(Field<String> field,
                                 Field<? extends Number> length)
Get the lpad(field, length) function

This renders the lpad function where available:

lpad([field], [length])
... or simulates it elsewhere using concat, repeat, and length, which may be simulated as well, depending on the RDBMS:
concat(repeat(' ', [length] - length([field])), [field])


lpad

public static Field<String> lpad(Field<String> field,
                                 int length,
                                 char character)
Get the lpad(field, length, character) function

See Also:
lpad(Field, Field, Field)

lpad

public static Field<String> lpad(Field<String> field,
                                 int length,
                                 String character)
Get the lpad(field, length, character) function

See Also:
lpad(Field, Field, Field)

lpad

public static Field<String> lpad(Field<String> field,
                                 Field<? extends Number> length,
                                 Field<String> character)
Get the lpad(field, length, character) function

This renders the lpad function where available:

lpad([field], [length])
... or simulates it elsewhere using concat, repeat, and length, which may be simulated as well, depending on the RDBMS:
concat(repeat([character], [length] - length([field])), [field])


repeat

public static Field<String> repeat(String field,
                                   int count)
Get the repeat(field, count) function

See Also:
repeat(Field, Field)

repeat

public static Field<String> repeat(String field,
                                   Field<? extends Number> count)
Get the repeat(field, count) function

See Also:
repeat(Field, Field)

repeat

public static Field<String> repeat(Field<String> field,
                                   int count)
Get the repeat(count) function

See Also:
repeat(Field, Field)

repeat

public static Field<String> repeat(Field<String> field,
                                   Field<? extends Number> count)
Get the repeat(field, count) function

This renders the repeat or replicate function where available:

repeat([field], [count]) or
 replicate([field], [count])
... or simulates it elsewhere using rpad and length, which may be simulated as well, depending on the RDBMS:
rpad([field], length([field]) * [count], [field])


escape

public static String escape(String value,
                            char escape)
Convenience method for replace(Field, String, String) to escape data for use with Field.like(Field, char)

Essentially, this escapes % and _ characters

See Also:
replace(Field, String, String), Field.like(Field, char)

escape

public static Field<String> escape(Field<String> field,
                                   char escape)
Convenience method for replace(Field, String, String) to escape data for use with Field.like(Field, char)

Essentially, this escapes % and _ characters

See Also:
replace(Field, String, String), Field.like(Field, char)

replace

public static Field<String> replace(Field<String> field,
                                    String search)
Get the replace(field, search) function

See Also:
replace(Field, Field)

replace

public static Field<String> replace(Field<String> field,
                                    Field<String> search)
Get the replace(field, search) function

This renders the replace or str_replace function where available:

replace([field], [search]) or
 str_replace([field], [search])
... or simulates it elsewhere using the three-argument replace function:
replace([field], [search], '')


replace

public static Field<String> replace(Field<String> field,
                                    String search,
                                    String replace)
Get the replace(field, search, replace) function

See Also:
replace(Field, Field, Field)

replace

public static Field<String> replace(Field<String> field,
                                    Field<String> search,
                                    Field<String> replace)
Get the replace(field, search, replace) function

This renders the replace or str_replace function:

replace([field], [search]) or
 str_replace([field], [search])


position

public static Field<Integer> position(String in,
                                      String search)
Get the position(in, search) function

See Also:
position(Field, Field)

position

public static Field<Integer> position(String in,
                                      Field<String> search)
Get the position(in, search) function

See Also:
position(Field, Field)

position

public static Field<Integer> position(Field<String> in,
                                      String search)
Get the position(in, search) function

See Also:
position(Field, Field)

position

public static Field<Integer> position(Field<String> in,
                                      Field<String> search)
Get the position(in, search) function

This renders the position or any equivalent function:

position([search] in [in]) or
 locate([in], [search]) or
 locate([search], [in]) or
 instr([in], [search]) or
 charindex([search], [in])


ascii

public static Field<Integer> ascii(String field)
Get the ascii(field) function

See Also:
ascii(Field)

ascii

public static Field<Integer> ascii(Field<String> field)
Get the ascii(field) function

This renders the ascii function:

ascii([field])


concat

public static Field<String> concat(String... values)
Get the concat(value[, value, ...]) function

See Also:
concat(Field...)

concat

public static Field<String> concat(Field<?>... fields)
Get the concat(field[, field, ...]) function

This creates fields[0] || fields[1] || ... as an expression, or concat(fields[0], fields[1], ...), depending on the dialect.

If any of the given fields is not a String field, they are cast to Field<String> first using cast(Object, Class)


substring

public static Field<String> substring(Field<String> field,
                                      int startingPosition)
Get the substring(field, startingPosition) function

See Also:
substring(Field, Field)

substring

public static Field<String> substring(Field<String> field,
                                      Field<? extends Number> startingPosition)
Get the substring(field, startingPosition) function

This renders the substr or substring function:

substr([field], [startingPosition]) or
 substring([field], [startingPosition])


substring

public static Field<String> substring(Field<String> field,
                                      int startingPosition,
                                      int length)
Get the substring(field, startingPosition, length) function

See Also:
substring(Field, Field, Field)

substring

public static Field<String> substring(Field<String> field,
                                      Field<? extends Number> startingPosition,
                                      Field<? extends Number> length)
Get the substring(field, startingPosition, length) function

This renders the substr or substring function:

substr([field], [startingPosition], [length]) or
 substring([field], [startingPosition], [length])


length

public static Field<Integer> length(String value)
Get the length of a VARCHAR type. This is a synonym for charLength(String)

See Also:
charLength(String)

length

public static Field<Integer> length(Field<String> field)
Get the length of a VARCHAR type. This is a synonym for charLength(Field)

See Also:
charLength(Field)

charLength

public static Field<Integer> charLength(String value)
Get the char_length(field) function

This translates into any dialect


charLength

public static Field<Integer> charLength(Field<String> field)
Get the char_length(field) function

This translates into any dialect


bitLength

public static Field<Integer> bitLength(String value)
Get the bit_length(field) function

This translates into any dialect


bitLength

public static Field<Integer> bitLength(Field<String> field)
Get the bit_length(field) function

This translates into any dialect


octetLength

public static Field<Integer> octetLength(String value)
Get the octet_length(field) function

This translates into any dialect


octetLength

public static Field<Integer> octetLength(Field<String> field)
Get the octet_length(field) function

This translates into any dialect


currentDate

public static Field<Date> currentDate()
Get the current_date() function

This translates into any dialect


currentTime

public static Field<Time> currentTime()
Get the current_time() function

This translates into any dialect


currentTimestamp

public static Field<Timestamp> currentTimestamp()
Get the current_timestamp() function

This translates into any dialect


dateDiff

public static Field<Integer> dateDiff(Date date1,
                                      Date date2)
Get the date difference in number of days

This translates into any dialect

See Also:
Field.sub(Field)

dateDiff

public static Field<Integer> dateDiff(Field<Date> date1,
                                      Date date2)
Get the date difference in number of days

This translates into any dialect

See Also:
Field.sub(Field)

dateDiff

public static Field<Integer> dateDiff(Date date1,
                                      Field<Date> date2)
Get the date difference in number of days

This translates into any dialect

See Also:
Field.sub(Field)

dateDiff

public static Field<Integer> dateDiff(Field<Date> date1,
                                      Field<Date> date2)
Get the date difference in number of days

This translates into any dialect

See Also:
Field.sub(Field)

timestampDiff

public static Field<DayToSecond> timestampDiff(Timestamp timestamp1,
                                               Timestamp timestamp2)
Get the timestamp difference as a INTERVAL DAY TO SECOND type

This translates into any dialect

See Also:
Field.sub(Field)

timestampDiff

public static Field<DayToSecond> timestampDiff(Field<Timestamp> timestamp1,
                                               Timestamp timestamp2)
Get the timestamp difference as a INTERVAL DAY TO SECOND type

This translates into any dialect

See Also:
Field.sub(Field)

timestampDiff

public static Field<DayToSecond> timestampDiff(Timestamp timestamp1,
                                               Field<Timestamp> timestamp2)
Get the timestamp difference as a INTERVAL DAY TO SECOND type

This translates into any dialect

See Also:
Field.sub(Field)

timestampDiff

public static Field<DayToSecond> timestampDiff(Field<Timestamp> timestamp1,
                                               Field<Timestamp> timestamp2)
Get the timestamp difference as a INTERVAL DAY TO SECOND type

This translates into any dialect

See Also:
Field.sub(Field)

extract

public static Field<Integer> extract(Date value,
                                     DatePart datePart)
Get the extract(field, datePart) function

This translates into any dialect


extract

public static Field<Integer> extract(Field<? extends Date> field,
                                     DatePart datePart)
Get the extract(field, datePart) function

This translates into any dialect


year

public static Field<Integer> year(Date value)
Get the year part of a date

This is the same as calling extract(java.util.Date, DatePart) with DatePart.YEAR


year

public static Field<Integer> year(Field<? extends Date> field)
Get the year part of a date

This is the same as calling extract(Field, DatePart) with DatePart.YEAR


month

public static Field<Integer> month(Date value)
Get the month part of a date

This is the same as calling extract(java.util.Date, DatePart) with DatePart.MONTH


month

public static Field<Integer> month(Field<? extends Date> field)
Get the month part of a date

This is the same as calling extract(Field, DatePart) with DatePart.MONTH


day

public static Field<Integer> day(Date value)
Get the day part of a date

This is the same as calling extract(java.util.Date, DatePart) with DatePart.DAY


day

public static Field<Integer> day(Field<? extends Date> field)
Get the day part of a date

This is the same as calling extract(Field, DatePart) with DatePart.DAY


hour

public static Field<Integer> hour(Date value)
Get the hour part of a date

This is the same as calling extract(java.util.Date, DatePart) with DatePart.HOUR


hour

public static Field<Integer> hour(Field<? extends Date> field)
Get the hour part of a date

This is the same as calling extract(Field, DatePart) with DatePart.HOUR


minute

public static Field<Integer> minute(Date value)
Get the minute part of a date

This is the same as calling extract(java.util.Date, DatePart) with DatePart.MINUTE


minute

public static Field<Integer> minute(Field<? extends Date> field)
Get the minute part of a date

This is the same as calling extract(Field, DatePart) with DatePart.MINUTE


second

public static Field<Integer> second(Date value)
Get the second part of a date

This is the same as calling extract(java.util.Date, DatePart) with DatePart.SECOND


second

public static Field<Integer> second(Field<? extends Date> field)
Get the second part of a date

This is the same as calling extract(Field, DatePart) with DatePart.SECOND


rollup

public static Field<?> rollup(Field<?>... fields)
Create a ROLLUP(field1, field2, .., fieldn) grouping field

This has been observed to work with the following databases:

Please check the SQL Server documentation for a very nice explanation of CUBE, ROLLUP, and GROUPING SETS clauses in grouping contexts: http://msdn.microsoft.com/en-US/library/bb522495.aspx

Parameters:
fields - The fields that are part of the ROLLUP function
Returns:
A field to be used in a GROUP BY clause

cube

public static Field<?> cube(Field<?>... fields)
Create a CUBE(field1, field2, .., fieldn) grouping field

This has been observed to work with the following databases:

Please check the SQL Server documentation for a very nice explanation of CUBE, ROLLUP, and GROUPING SETS clauses in grouping contexts: http://msdn.microsoft.com/en-US/library/bb522495.aspx

Parameters:
fields - The fields that are part of the CUBE function
Returns:
A field to be used in a GROUP BY clause

groupingSets

public static Field<?> groupingSets(Field<?>... fields)
Create a GROUPING SETS(field1, field2, .., fieldn) grouping field where each grouping set only consists of a single field.

This has been observed to work with the following databases:

Please check the SQL Server documentation for a very nice explanation of CUBE, ROLLUP, and GROUPING SETS clauses in grouping contexts: http://msdn.microsoft.com/en-US/library/bb522495.aspx

Parameters:
fields - The fields that are part of the GROUPING SETS function
Returns:
A field to be used in a GROUP BY clause

groupingSets

public static Field<?> groupingSets(Field<?>[]... fieldSets)
Create a GROUPING SETS((field1a, field1b), (field2a), .., (fieldna, fieldnb)) grouping field

This has been observed to work with the following databases:

Please check the SQL Server documentation for a very nice explanation of CUBE, ROLLUP, and GROUPING SETS clauses in grouping contexts: http://msdn.microsoft.com/en-US/library/bb522495.aspx

Parameters:
fieldSets - The fields that are part of the GROUPING SETS function
Returns:
A field to be used in a GROUP BY clause

groupingSets

public static Field<?> groupingSets(Collection<Field<?>>... fieldSets)
Create a GROUPING SETS((field1a, field1b), (field2a), .., (fieldna, fieldnb)) grouping field

This has been observed to work with the following databases:

Please check the SQL Server documentation for a very nice explanation of CUBE, ROLLUP, and GROUPING SETS clauses in grouping contexts: http://msdn.microsoft.com/en-US/library/bb522495.aspx

Parameters:
fieldSets - The fields that are part of the GROUPING SETS function
Returns:
A field to be used in a GROUP BY clause

grouping

public static Field<Integer> grouping(Field<?> field)
Create a GROUPING(field) aggregation field to be used along with CUBE, ROLLUP, and GROUPING SETS groupings

This has been observed to work with the following databases:

Parameters:
field - The function argument
Returns:
The GROUPING aggregation field
See Also:
cube(Field...), rollup(Field...)

groupingId

public static Field<Integer> groupingId(Field<?>... fields)
Create a GROUPING_ID(field1, field2, .., fieldn) aggregation field to be used along with CUBE, ROLLUP, and GROUPING SETS groupings

This has been observed to work with the following databases:

Parameters:
fields - The function arguments
Returns:
The GROUPING_ID aggregation field
See Also:
cube(Field...), rollup(Field...)

bitCount

public static Field<Integer> bitCount(Number value)
The MySQL BIT_COUNT(field) function, counting the number of bits that are set in this number.

See Also:
bitCount(Field)

bitCount

public static Field<Integer> bitCount(Field<? extends Number> field)
The MySQL BIT_COUNT(field) function, counting the number of bits that are set in this number.

This function is simulated in most other databases like this (for a TINYINT field):

 ([field] &   1) +
 ([field] &   2) >> 1 +
 ([field] &   4) >> 2 +
 ([field] &   8) >> 3 +
 ([field] &  16) >> 4 +
  ...
 ([field] & 128) >> 7
 

More efficient algorithms are very welcome


bitNot

public static <T extends Number> Field<T> bitNot(T value)
The bitwise not operator.

See Also:
bitNot(Field)

bitNot

public static <T extends Number> Field<T> bitNot(Field<T> field)
The bitwise not operator.

Most dialects natively support this using ~[field]. jOOQ simulates this operator in some dialects using -[field] - 1


bitAnd

public static <T extends Number> Field<T> bitAnd(T value1,
                                                 T value2)
The bitwise and operator.

See Also:
bitAnd(Field, Field)

bitAnd

public static <T extends Number> Field<T> bitAnd(T value1,
                                                 Field<T> value2)
The bitwise and operator.

See Also:
bitAnd(Field, Field)

bitAnd

public static <T extends Number> Field<T> bitAnd(Field<T> value1,
                                                 T value2)
The bitwise and operator.

See Also:
bitAnd(Field, Field)

bitAnd

public static <T extends Number> Field<T> bitAnd(Field<T> field1,
                                                 Field<T> field2)
The bitwise and operator.

This is not supported by Derby, Ingres

This renders the and operation where available:

[field1] & [field2]
... or the and function elsewhere:
bitand([field1], [field2])


bitNand

public static <T extends Number> Field<T> bitNand(T value1,
                                                  T value2)
The bitwise not and operator.

See Also:
bitNand(Field, Field), bitNot(Field)

bitNand

public static <T extends Number> Field<T> bitNand(T value1,
                                                  Field<T> value2)
The bitwise not and operator.

See Also:
bitNand(Field, Field), bitNot(Field)

bitNand

public static <T extends Number> Field<T> bitNand(Field<T> value1,
                                                  T value2)
The bitwise not and operator.

See Also:
bitNand(Field, Field), bitNot(Field)

bitNand

public static <T extends Number> Field<T> bitNand(Field<T> field1,
                                                  Field<T> field2)
The bitwise not and operator.

This is not supported by Derby, Ingres

This renders the not and operation where available:

~([field1] & [field2])
... or the not and function elsewhere:
bitnot(bitand([field1], [field2]))

See Also:
bitNot(Field)

bitOr

public static <T extends Number> Field<T> bitOr(T value1,
                                                T value2)
The bitwise or operator.

See Also:
bitOr(Field, Field)

bitOr

public static <T extends Number> Field<T> bitOr(T value1,
                                                Field<T> value2)
The bitwise or operator.

See Also:
bitOr(Field, Field)

bitOr

public static <T extends Number> Field<T> bitOr(Field<T> value1,
                                                T value2)
The bitwise or operator.

See Also:
bitOr(Field, Field)

bitOr

public static <T extends Number> Field<T> bitOr(Field<T> field1,
                                                Field<T> field2)
The bitwise or operator.

This is not supported by Derby, Ingres

This renders the or operation where available:

[field1] | [field2]
... or the or function elsewhere:
bitor([field1], [field2])


bitNor

public static <T extends Number> Field<T> bitNor(T value1,
                                                 T value2)
The bitwise not or operator.

See Also:
bitNor(Field, Field), bitNot(Field)

bitNor

public static <T extends Number> Field<T> bitNor(T value1,
                                                 Field<T> value2)
The bitwise not or operator.

See Also:
bitNor(Field, Field), bitNot(Field)

bitNor

public static <T extends Number> Field<T> bitNor(Field<T> value1,
                                                 T value2)
The bitwise not or operator.

See Also:
bitNor(Field, Field), bitNot(Field)

bitNor

public static <T extends Number> Field<T> bitNor(Field<T> field1,
                                                 Field<T> field2)
The bitwise not or operator.

This is not supported by Derby, Ingres

This renders the not or operation where available:

~([field1] | [field2])
... or the not or function elsewhere:
bitnot(bitor([field1], [field2]))

See Also:
bitNot(Field)

bitXor

public static <T extends Number> Field<T> bitXor(T value1,
                                                 T value2)
The bitwise xor operator.

See Also:
bitXor(Field, Field)

bitXor

public static <T extends Number> Field<T> bitXor(T value1,
                                                 Field<T> value2)
The bitwise xor operator.

See Also:
bitXor(Field, Field)

bitXor

public static <T extends Number> Field<T> bitXor(Field<T> value1,
                                                 T value2)
The bitwise xor operator.

See Also:
bitXor(Field, Field)

bitXor

public static <T extends Number> Field<T> bitXor(Field<T> field1,
                                                 Field<T> field2)
The bitwise xor operator.

This is not supported by Derby, Ingres

This renders the or operation where available:

[field1] ^ [field2]
... or the xor function elsewhere:
bitxor([field1], [field2])


bitXNor

public static <T extends Number> Field<T> bitXNor(T value1,
                                                  T value2)
The bitwise not xor operator.

See Also:
bitXNor(Field, Field), bitNot(Field)

bitXNor

public static <T extends Number> Field<T> bitXNor(T value1,
                                                  Field<T> value2)
The bitwise not xor operator.

See Also:
bitXNor(Field, Field), bitNot(Field)

bitXNor

public static <T extends Number> Field<T> bitXNor(Field<T> value1,
                                                  T value2)
The bitwise not xor operator.

See Also:
bitXNor(Field, Field), bitNot(Field)

bitXNor

public static <T extends Number> Field<T> bitXNor(Field<T> field1,
                                                  Field<T> field2)
The bitwise not xor operator.

This is not supported by Derby, Ingres

This renders the or operation where available:

~([field1] ^ [field2])
... or the not xor function elsewhere:
bitnot(bitxor([field1], [field2]))


shl

public static <T extends Number> Field<T> shl(T value1,
                                              T value2)
The bitwise left shift operator.

See Also:
shl(Field, Field), power(Field, Number)

shl

public static <T extends Number> Field<T> shl(T value1,
                                              Field<T> value2)
The bitwise left shift operator.

See Also:
shl(Field, Field), power(Field, Number)

shl

public static <T extends Number> Field<T> shl(Field<T> value1,
                                              T value2)
The bitwise left shift operator.

See Also:
shl(Field, Field), power(Field, Number)

shl

public static <T extends Number> Field<T> shl(Field<T> field1,
                                              Field<T> field2)
The bitwise left shift operator.

Some dialects natively support this using [field1] << [field2]. jOOQ simulates this operator in some dialects using [field1] * power(2, [field2]), where power might also be simulated.

See Also:
power(Field, Field)

shr

public static <T extends Number> Field<T> shr(T value1,
                                              T value2)
The bitwise right shift operator.

See Also:
shr(Field, Field), power(Field, Number)

shr

public static <T extends Number> Field<T> shr(T value1,
                                              Field<T> value2)
The bitwise right shift operator.

See Also:
shr(Field, Field), power(Field, Number)

shr

public static <T extends Number> Field<T> shr(Field<T> value1,
                                              T value2)
The bitwise right shift operator.

See Also:
shr(Field, Field), power(Field, Number)

shr

public static <T extends Number> Field<T> shr(Field<T> field1,
                                              Field<T> field2)
The bitwise right shift operator.

Some dialects natively support this using [field1] >> [field2]. jOOQ simulates this operator in some dialects using [field1] / power(2, [field2]), where power might also be simulated.

See Also:
power(Field, Field)

greatest

public static <T> Field<T> greatest(T value,
                                    T... values)
Find the greatest among all values

This function has no equivalent in Adaptive Server, Derby, SQL Server and Sybase SQL Anywhere. Its current simulation implementation has O(2^n) complexity and should be avoided for n > 5! Better implementation suggestions are very welcome.

See Also:
greatest(Field, Field...)

greatest

public static <T> Field<T> greatest(Field<T> field,
                                    Field<?>... others)
Find the greatest among all values

This function has no equivalent in Adaptive Server, Derby, SQL Server and Sybase SQL Anywhere. Its current simulation implementation has O(2^n) complexity and should be avoided for n > 5! Better implementation suggestions are very welcome.


least

public static <T> Field<T> least(T value,
                                 T... values)
Find the least among all values

This function has no equivalent in Adaptive Server, Derby, SQL Server and Sybase SQL Anywhere. Its current simulation implementation has O(2^n) complexity and should be avoided for n > 5! Better implementation suggestions are very welcome.

See Also:
least(Field, Field...)

least

public static <T> Field<T> least(Field<T> field,
                                 Field<?>... others)
Find the least among all values

This function has no equivalent in Adaptive Server, Derby, SQL Server and Sybase SQL Anywhere. Its current simulation implementation has O(2^n) complexity and should be avoided for n > 5! Better implementation suggestions are very welcome.


sign

public static Field<Integer> sign(Number value)
Get the sign of a numeric field: sign(field)

See Also:
sign(Field)

sign

public static Field<Integer> sign(Field<? extends Number> field)
Get the sign of a numeric field: sign(field)

This renders the sign function where available:

sign([field])
... or simulates it elsewhere (without bind variables on values -1, 0, 1):
 CASE WHEN [this] > 0 THEN 1
      WHEN [this] < 0 THEN -1
      ELSE 0
 END


abs

public static <T extends Number> Field<T> abs(T value)
Get the absolute value of a numeric field: abs(field)

See Also:
abs(Field)

abs

public static <T extends Number> Field<T> abs(Field<T> field)
Get the absolute value of a numeric field: abs(field)

This renders the same on all dialects:

abs([field])


round

public static <T extends Number> Field<T> round(T value)
Get rounded value of a numeric field: round(field)

See Also:
round(Field)

round

public static <T extends Number> Field<T> round(Field<T> field)
Get rounded value of a numeric field: round(field)

This renders the round function where available:

round([field]) or
 round([field], 0)
... or simulates it elsewhere using floor and ceil


round

public static <T extends Number> Field<T> round(T value,
                                                int decimals)
Get rounded value of a numeric field: round(field, decimals)

See Also:
round(Field, int)

round

public static <T extends Number> Field<T> round(Field<T> field,
                                                int decimals)
Get rounded value of a numeric field: round(field, decimals)

This renders the round function where available:

round([field], [decimals])
... or simulates it elsewhere using floor and ceil


floor

public static <T extends Number> Field<T> floor(T value)
Get the largest integer value not greater than [this]

See Also:
floor(Field)

floor

public static <T extends Number> Field<T> floor(Field<T> field)
Get the largest integer value not greater than [this]

This renders the floor function where available:

floor([this])
... or simulates it elsewhere using round:
round([this] - 0.499999999999999)


ceil

public static <T extends Number> Field<T> ceil(T value)
Get the smallest integer value not less than [this]

See Also:
ceil(Field)

ceil

public static <T extends Number> Field<T> ceil(Field<T> field)
Get the smallest integer value not less than [field]

This renders the ceil or ceiling function where available:

ceil([field]) or
 ceiling([field])
... or simulates it elsewhere using round:
round([field] + 0.499999999999999)


sqrt

public static Field<BigDecimal> sqrt(Number value)
Get the sqrt(field) function

See Also:
sqrt(Field)

sqrt

public static Field<BigDecimal> sqrt(Field<? extends Number> field)
Get the sqrt(field) function

This renders the sqrt function where available:

sqrt([field])
... or simulates it elsewhere using power (which in turn may also be simulated using ln and exp functions):
power([field], 0.5)


exp

public static Field<BigDecimal> exp(Number value)
Get the exp(field) function, taking this field as the power of e

See Also:
exp(Field)

exp

public static Field<BigDecimal> exp(Field<? extends Number> field)
Get the exp(field) function, taking this field as the power of e

This renders the same on all dialects:

exp([field])


ln

public static Field<BigDecimal> ln(Number value)
Get the ln(field) function, taking the natural logarithm of this field

See Also:
ln(Field)

ln

public static Field<BigDecimal> ln(Field<? extends Number> field)
Get the ln(field) function, taking the natural logarithm of this field

This renders the ln or log function where available:

ln([field]) or
 log([field])


log

public static Field<BigDecimal> log(Number value,
                                    int base)
Get the log(field, base) function

See Also:
log(Field, int)

log

public static Field<BigDecimal> log(Field<? extends Number> field,
                                    int base)
Get the log(field, base) function

This renders the log function where available:

log([field])
... or simulates it elsewhere (in most RDBMS) using the natural logarithm:
ln([field]) / ln([base])


power

public static Field<BigDecimal> power(Number value,
                                      Number exponent)
Get the power(field, exponent) function

See Also:
power(Field, Field)

power

public static Field<BigDecimal> power(Field<? extends Number> field,
                                      Number exponent)
Get the power(field, exponent) function

See Also:
power(Field, Field)

power

public static Field<BigDecimal> power(Number value,
                                      Field<? extends Number> exponent)
Get the power(field, exponent) function

See Also:
power(Field, Field)

power

public static Field<BigDecimal> power(Field<? extends Number> field,
                                      Field<? extends Number> exponent)
Get the power(field, exponent) function

This renders the power function where available:

power([field], [exponent])
... or simulates it elsewhere using ln and exp:
exp(ln([field]) * [exponent])


acos

public static Field<BigDecimal> acos(Number value)
Get the arc cosine(field) function

See Also:
acos(Field)

acos

public static Field<BigDecimal> acos(Field<? extends Number> field)
Get the arc cosine(field) function

This renders the acos function where available:

acos([field])


asin

public static Field<BigDecimal> asin(Number value)
Get the arc sine(field) function

See Also:
asin(Field)

asin

public static Field<BigDecimal> asin(Field<? extends Number> field)
Get the arc sine(field) function

This renders the asin function where available:

asin([field])


atan

public static Field<BigDecimal> atan(Number value)
Get the arc tangent(field) function

See Also:
atan(Field)

atan

public static Field<BigDecimal> atan(Field<? extends Number> field)
Get the arc tangent(field) function

This renders the atan function where available:

atan([field])


atan2

public static Field<BigDecimal> atan2(Number x,
                                      Number y)
Get the atan2(field, y) function

See Also:
atan2(Field, Field)

atan2

public static Field<BigDecimal> atan2(Number x,
                                      Field<? extends Number> y)
Get the atan2(field, y) function

See Also:
atan2(Field, Field)

atan2

public static Field<BigDecimal> atan2(Field<? extends Number> x,
                                      Number y)
Get the atan2(field, y) function

See Also:
atan2(Field, Field)

atan2

public static Field<BigDecimal> atan2(Field<? extends Number> x,
                                      Field<? extends Number> y)
Get the atan2(field, y) function

This renders the atan2 or atn2 function where available:

atan2([x], [y]) or
 atn2([x], [y])


cos

public static Field<BigDecimal> cos(Number value)
Get the cosine(field) function

See Also:
cos(Field)

cos

public static Field<BigDecimal> cos(Field<? extends Number> field)
Get the cosine(field) function

This renders the cos function where available:

cos([field])


sin

public static Field<BigDecimal> sin(Number value)
Get the sine(field) function

See Also:
sin(Field)

sin

public static Field<BigDecimal> sin(Field<? extends Number> field)
Get the sine(field) function

This renders the sin function where available:

sin([field])


tan

public static Field<BigDecimal> tan(Number value)
Get the tangent(field) function

See Also:
tan(Field)

tan

public static Field<BigDecimal> tan(Field<? extends Number> field)
Get the tangent(field) function

This renders the tan function where available:

tan([field])


cot

public static Field<BigDecimal> cot(Number value)
Get the cotangent(field) function

See Also:
cot(Field)

cot

public static Field<BigDecimal> cot(Field<? extends Number> field)
Get the cotangent(field) function

This renders the cot function where available:

cot([field])
... or simulates it elsewhere using sin and cos:
cos([field]) / sin([field])


sinh

public static Field<BigDecimal> sinh(Number value)
Get the hyperbolic sine function: sinh(field)

See Also:
sinh(Field)

sinh

public static Field<BigDecimal> sinh(Field<? extends Number> field)
Get the hyperbolic sine function: sinh(field)

This renders the sinh function where available:

sinh([field])
... or simulates it elsewhere using exp:
(exp([field] * 2) - 1) / (exp([field] * 2))


cosh

public static Field<BigDecimal> cosh(Number value)
Get the hyperbolic cosine function: cosh(field)

See Also:
cosh(Field)

cosh

public static Field<BigDecimal> cosh(Field<? extends Number> field)
Get the hyperbolic cosine function: cosh(field)

This renders the cosh function where available:

cosh([field])
... or simulates it elsewhere using exp:
(exp([field] * 2) + 1) / (exp([field] * 2))


tanh

public static Field<BigDecimal> tanh(Number value)
Get the hyperbolic tangent function: tanh(field)

See Also:
tanh(Field)

tanh

public static Field<BigDecimal> tanh(Field<? extends Number> field)
Get the hyperbolic tangent function: tanh(field)

This renders the tanh function where available:

tanh([field])
... or simulates it elsewhere using exp:
(exp([field] * 2) - 1) / (exp([field] * 2) + 1)


coth

public static Field<BigDecimal> coth(Number value)
Get the hyperbolic cotangent function: coth(field)

See Also:
coth(Field)

coth

public static Field<BigDecimal> coth(Field<? extends Number> field)
Get the hyperbolic cotangent function: coth(field)

This is not supported by any RDBMS, but simulated using exp exp:

(exp([field] * 2) + 1) / (exp([field] * 2) - 1)


deg

public static Field<BigDecimal> deg(Number value)
Calculate degrees from radians from this field

See Also:
deg(Field)

deg

public static Field<BigDecimal> deg(Field<? extends Number> field)
Calculate degrees from radians from this field

This renders the degrees function where available:

degrees([field])
... or simulates it elsewhere:
[field] * 180 / PI


rad

public static Field<BigDecimal> rad(Number value)
Calculate radians from degrees from this field

See Also:
rad(Field)

rad

public static Field<BigDecimal> rad(Field<? extends Number> field)
Calculate radians from degrees from this field

This renders the degrees function where available:

degrees([field])
... or simulates it elsewhere:
[field] * PI / 180


level

public static Field<Integer> level()
Retrieve the Oracle-specific LEVEL pseudo-field (to be used along with CONNECT BY clauses)


connectByIsCycle

public static Field<Boolean> connectByIsCycle()
Retrieve the Oracle-specific CONNECT_BY_ISCYCLE pseudo-field (to be used along with CONNECT BY clauses)


connectByIsLeaf

public static Field<Boolean> connectByIsLeaf()
Retrieve the Oracle-specific CONNECT_BY_ISLEAF pseudo-field (to be used along with CONNECT BY clauses)


sysConnectByPath

public static Field<String> sysConnectByPath(Field<?> field,
                                             String separator)
Retrieve the Oracle-specific SYS_CONNECT_BY_PATH(field, separator) function (to be used along with CONNECT BY clauses).


prior

public static <T> Field<T> prior(Field<T> field)
Add the Oracle-specific PRIOR unary operator before a field (to be used along with CONNECT BY clauses)


count

public static AggregateFunction<Integer> count()
Get the count(*) function


count

public static AggregateFunction<Integer> count(Field<?> field)
Get the count(field) function


countDistinct

public static AggregateFunction<Integer> countDistinct(Field<?> field)
Get the count(distinct field) function


max

public static <T> AggregateFunction<T> max(Field<T> field)
Get the max value over a field: max(field)


maxDistinct

public static <T> AggregateFunction<T> maxDistinct(Field<T> field)
Get the max value over a field: max(distinct field)


min

public static <T> AggregateFunction<T> min(Field<T> field)
Get the min value over a field: min(field)


minDistinct

public static <T> AggregateFunction<T> minDistinct(Field<T> field)
Get the min value over a field: min(distinct field)


sum

public static AggregateFunction<BigDecimal> sum(Field<? extends Number> field)
Get the sum over a numeric field: sum(field)


sumDistinct

public static AggregateFunction<BigDecimal> sumDistinct(Field<? extends Number> field)
Get the sum over a numeric field: sum(distinct field)


avg

public static AggregateFunction<BigDecimal> avg(Field<? extends Number> field)
Get the average over a numeric field: avg(field)


avgDistinct

public static AggregateFunction<BigDecimal> avgDistinct(Field<? extends Number> field)
Get the average over a numeric field: avg(distinct field)


median

public static AggregateFunction<BigDecimal> median(Field<? extends Number> field)
Get the median over a numeric field: median(field)

This is known to be supported in any of these RDBMS:

  • HSQLDB
  • Oracle
  • Sybase SQL Anywhere


stddevPop

public static AggregateFunction<BigDecimal> stddevPop(Field<? extends Number> field)
Get the population standard deviation of a numeric field: stddev_pop(field)

This is known to be supported in any of these RDBMS:

  • DB2
  • H2
  • HSQLDB
  • Ingres
  • MySQL
  • Oracle
  • Postgres
  • SQL Server (stdev)
  • Sybase ASE
  • Sybase SQL Anywhere


stddevSamp

public static AggregateFunction<BigDecimal> stddevSamp(Field<? extends Number> field)
Get the sample standard deviation of a numeric field: stddev_samp(field)

This is known to be supported in any of these RDBMS:

  • DB2
  • H2
  • HSQLDB
  • Ingres
  • MySQL
  • Oracle
  • Postgres
  • SQL Server (stdev)
  • Sybase ASE
  • Sybase SQL Anywhere


varPop

public static AggregateFunction<BigDecimal> varPop(Field<? extends Number> field)
Get the population variance of a numeric field: var_pop(field)

This is known to be supported in any of these RDBMS:

  • DB2
  • H2
  • HSQLDB
  • Ingres
  • MySQL
  • Oracle
  • Postgres
  • SQL Server (stdev)
  • Sybase ASE
  • Sybase SQL Anywhere


varSamp

public static AggregateFunction<BigDecimal> varSamp(Field<? extends Number> field)
Get the sample variance of a numeric field: var_samp(field)

This is known to be supported in any of these RDBMS:

  • H2
  • HSQLDB
  • Ingres
  • MySQL
  • Oracle
  • Postgres
  • SQL Server (var)
  • Sybase SQL Anywhere


listAgg

public static OrderedAggregateFunction<String> listAgg(Field<?> field)
Get the aggregated concatenation for a field.

This is natively supported by SQLDialect.ORACLE. It is simulated by the following dialects:

See Also:
groupConcat(Field)

listAgg

public static OrderedAggregateFunction<String> listAgg(Field<?> field,
                                                       String separator)
Get the aggregated concatenation for a field.

This is natively supported by SQLDialect.ORACLE. It is simulated by the following dialects:

See Also:
groupConcat(Field)

groupConcat

public static GroupConcatOrderByStep groupConcat(Field<?> field)
Get the aggregated concatenation for a field.

This is natively supported by

It is simulated by the following dialects:

See Also:
listAgg(Field)

groupConcatDistinct

public static GroupConcatOrderByStep groupConcatDistinct(Field<?> field)
Get the aggregated concatenation for a field.

This is natively supported by

It is simulated by the following dialects:

See Also:
listAgg(Field)

rowNumber

public static WindowOverStep<Integer> rowNumber()
The row_number() over ([analytic clause]) function.

Window functions are supported in DB2, Postgres, Oracle, SQL Server and Sybase.


rank

public static WindowOverStep<Integer> rank()
The rank_over() over ([analytic clause]) function.

Window functions are supported in DB2, Postgres, Oracle, SQL Server and Sybase.


denseRank

public static WindowOverStep<Integer> denseRank()
The dense_rank() over ([analytic clause]) function.

Window functions are supported in DB2, Postgres, Oracle, SQL Server and Sybase.


percentRank

public static WindowOverStep<BigDecimal> percentRank()
The precent_rank() over ([analytic clause]) function.

Window functions are supported in DB2, Postgres, Oracle, SQL Server and Sybase.


cumeDist

public static WindowOverStep<BigDecimal> cumeDist()
The cume_dist() over ([analytic clause]) function.

Window functions are supported in DB2, Postgres, Oracle, SQL Server and Sybase.


ntile

public static WindowOverStep<Integer> ntile(int number)
The ntile([number]) over ([analytic clause]) function.

Window functions are supported in DB2, Postgres, Oracle, SQL Server and Sybase.


firstValue

public static <T> WindowIgnoreNullsStep<T> firstValue(Field<T> field)
The first_value(field) over ([analytic clause]) function.

Window functions are supported in DB2, Postgres, Oracle, SQL Server and Sybase.


lastValue

public static <T> WindowIgnoreNullsStep<T> lastValue(Field<T> field)
The last_value(field) over ([analytic clause]) function.

Window functions are supported in DB2, Postgres, Oracle, SQL Server and Sybase.


lead

public static <T> WindowIgnoreNullsStep<T> lead(Field<T> field)
The lead(field) over ([analytic clause]) function.

Window functions are supported in DB2, Postgres, Oracle, SQL Server and Sybase.


lead

public static <T> WindowIgnoreNullsStep<T> lead(Field<T> field,
                                                int offset)
The lead(field, offset) over ([analytic clause]) function.

Window functions are supported in DB2, Postgres, Oracle, SQL Server and Sybase.


lead

public static <T> WindowIgnoreNullsStep<T> lead(Field<T> field,
                                                int offset,
                                                T defaultValue)
The lead(field, offset, defaultValue) over ([analytic clause]) function.

Window functions are supported in DB2, Postgres, Oracle, SQL Server and Sybase.


lead

public static <T> WindowIgnoreNullsStep<T> lead(Field<T> field,
                                                int offset,
                                                Field<T> defaultValue)
The lead(field, offset, defaultValue) over ([analytic clause]) function.

Window functions are supported in DB2, Postgres, Oracle, SQL Server and Sybase.


lag

public static <T> WindowIgnoreNullsStep<T> lag(Field<T> field)
The lag(field) over ([analytic clause]) function.

Window functions are supported in DB2, Postgres, Oracle, SQL Server and Sybase.


lag

public static <T> WindowIgnoreNullsStep<T> lag(Field<T> field,
                                               int offset)
The lag(field, offset) over ([analytic clause]) function.

Window functions are supported in DB2, Postgres, Oracle, SQL Server and Sybase.


lag

public static <T> WindowIgnoreNullsStep<T> lag(Field<T> field,
                                               int offset,
                                               T defaultValue)
The lag(field, offset, defaultValue) over ([analytic clause]) function.

Window functions are supported in DB2, Postgres, Oracle, SQL Server and Sybase.


lag

public static <T> WindowIgnoreNullsStep<T> lag(Field<T> field,
                                               int offset,
                                               Field<T> defaultValue)
The lag(field, offset, defaultValue) over ([analytic clause]) function.

Window functions are supported in DB2, Postgres, Oracle, SQL Server and Sybase.


param

public static Param<Object> param(String name)
Create a named parameter with a generic type (Object / SQLDataType.OTHER) and no initial value.

Try to avoid this method when using any of these databases, as these databases may have trouble inferring the type of the bind value. Use typed named parameters instead, using param(String, Class) or param(String, DataType)

See Also:
param(String, Object)

param

public static <T> Param<T> param(String name,
                                 Class<? extends T> type)
Create a named parameter with a defined type and no initial value.

See Also:
param(String, Object)

param

public static <T> Param<T> param(String name,
                                 DataType<T> type)
Create a named parameter with a defined type and no initial value.

See Also:
param(String, Object)

param

public static <T> Param<T> param(String name,
                                 T value)
Create a named parameter with an initial value.

Named parameters are useful for several use-cases:

See Also:
Query.getParam(String), Query.getParams(), renderNamedParams(QueryPart)

value

public static <T> Field<T> value(T value)
A synonym for val(Object) to be used in Scala and Groovy, where val is a reserved keyword.

See Also:
val(Object)

value

public static <T> Field<T> value(Object value,
                                 Class<? extends T> type)
A synonym for val(Object) to be used in Scala and Groovy, where val is a reserved keyword.

See Also:
val(Object, Class)

value

public static <T> Field<T> value(Object value,
                                 Field<T> field)
A synonym for val(Object) to be used in Scala and Groovy, where val is a reserved keyword.

See Also:
val(Object, Field)

value

public static <T> Field<T> value(Object value,
                                 DataType<T> type)
A synonym for val(Object) to be used in Scala and Groovy, where val is a reserved keyword.

See Also:
val(Object, DataType)

val

public static <T> Field<T> val(T value)
Get a bind value

jOOQ tries to derive the RDBMS DataType from the provided Java type <T>. This may not always be accurate, which can lead to problems in some strongly typed RDMBS, especially when value is null. These databases are namely:

If you need more type-safety, please use val(Object, DataType) instead, and provide the precise RDMBS-specific data type, that is needed.

Type Parameters:
T - The generic value type
Parameters:
value - The constant value
Returns:
A field representing the constant value

val

public static <T> Field<T> val(Object value,
                               Class<? extends T> type)
Get a bind value with an associated type, taken from a field

Type Parameters:
T - The generic value type
Parameters:
value - The constant value
type - The data type to enforce upon the value
Returns:
A field representing the constant value
See Also:
val(Object, DataType)

val

public static <T> Field<T> val(Object value,
                               Field<T> field)
Get a bind value with an associated type, taken from a field

Type Parameters:
T - The generic value type
Parameters:
value - The constant value
field - The field whose data type to enforce upon the value
Returns:
A field representing the constant value
See Also:
val(Object, DataType)

val

public static <T> Field<T> val(Object value,
                               DataType<T> type)
Get a bind value with an associated type

This will try to bind value as type in a PreparedStatement. If value and type are not compatible, jOOQ will first try to convert and then to cast value to type.

Type Parameters:
T - The generic value type
Parameters:
value - The constant value
type - The data type to enforce upon the value
Returns:
A field representing the constant value

vals

public static List<Field<?>> vals(Object... values)
Get a list of bind values and fields


literal

public static <T> Field<T> literal(T literal)
Get a typed Field for a literal.

This is similar as calling field(String). A field without bind variables will be generated.

NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

Type Parameters:
T - The generic field type
Parameters:
literal - The literal
Returns:
The literal as a field

literal

public static <T> Field<T> literal(Object literal,
                                   Class<T> type)
Get a typed Field for a literal.

This is similar as calling field(String). A field without bind variables will be generated.

NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

Type Parameters:
T - The generic field type
Parameters:
literal - The literal
type - The literal's data type
Returns:
The literal as a field

literal

public static <T> Field<T> literal(Object literal,
                                   DataType<T> type)
Get a typed Field for a literal.

This is similar as calling field(String). A field without bind variables will be generated.

NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity. You may also create the possibility of malicious SQL injection. Be sure to properly use bind variables and/or escape literals when concatenated into SQL clauses!

Type Parameters:
T - The generic field type
Parameters:
literal - The literal
type - The literal's data type
Returns:
The literal as a field

zero

public static Field<Integer> zero()
A 0 literal.

This is useful for mathematical functions or for EXISTS (SELECT 0 ...) or PARTITION BY 0 clauses and similar constructs. The 0 literal will not generate a bind variable.

Returns:
A 0 literal as a Field

one

public static Field<Integer> one()
A 1 literal.

This is useful for mathematical functions or for EXISTS (SELECT 1 ...) or PARTITION BY 1 clauses and similar constructs. The 1 literal will not generate a bind variable.

Returns:
A 1 literal as a Field

two

public static Field<Integer> two()
A 2 literal.

This is useful for mathematical functions. The 1 literal will not generate a bind variable.

Returns:
A 2 literal as a Field

pi

public static Field<BigDecimal> pi()
The PI literal.

This will be any of the following:

  • The underlying RDBMS' PI literal or PI() function
  • Math.PI


e

public static Field<BigDecimal> e()
The E literal (Euler number)

This will be any of the following:

  • The underlying RDBMS' E literal or E() function
  • Math.E


currentUser

public static Field<String> currentUser()
Get the current_user() function

This translates into any dialect


rand

public static Field<BigDecimal> rand()
Get the rand() function


fetch

public final <R extends Record> Result<R> fetch(Table<R> table)
Execute and return all records for
SELECT * FROM [table]

Specified by:
fetch in interface FactoryOperations

fetch

public final <R extends Record> Result<R> fetch(Table<R> table,
                                                Condition condition)
Execute and return all records for
SELECT * FROM [table] WHERE [condition] 

Specified by:
fetch in interface FactoryOperations

fetchOne

public final <R extends Record> R fetchOne(Table<R> table)
Execute and return zero or one record for
SELECT * FROM [table]

Specified by:
fetchOne in interface FactoryOperations
Returns:
The record or null if no record was returned

fetchOne

public final <R extends Record> R fetchOne(Table<R> table,
                                           Condition condition)
Execute and return zero or one record for
SELECT * FROM [table] WHERE [condition] 

Specified by:
fetchOne in interface FactoryOperations
Returns:
The record or null if no record was returned

fetchAny

public final <R extends Record> R fetchAny(Table<R> table)
Execute and return zero or one record for
SELECT * FROM [table] LIMIT 1

Specified by:
fetchAny in interface FactoryOperations
Returns:
The record or null if no record was returned

executeInsert

public final <R extends TableRecord<R>> int executeInsert(Table<R> table,
                                                          R record)
Insert one record
INSERT INTO [table] ... VALUES [record] 

Specified by:
executeInsert in interface FactoryOperations
Returns:
The number of inserted records

executeUpdate

public final <R extends TableRecord<R>> int executeUpdate(Table<R> table,
                                                          R record)
Update a table
UPDATE [table] SET [modified values in record] 

Specified by:
executeUpdate in interface FactoryOperations
Returns:
The number of updated records

executeUpdate

public final <R extends TableRecord<R>,T> int executeUpdate(Table<R> table,
                                                            R record,
                                                            Condition condition)
Update a table
UPDATE [table] SET [modified values in record] WHERE [condition]

Specified by:
executeUpdate in interface FactoryOperations
Returns:
The number of updated records

executeUpdateOne

public final <R extends TableRecord<R>> int executeUpdateOne(Table<R> table,
                                                             R record)
Update one record in a table
UPDATE [table] SET [modified values in record]

Specified by:
executeUpdateOne in interface FactoryOperations
Returns:
The number of updated records

executeUpdateOne

public final <R extends TableRecord<R>,T> int executeUpdateOne(Table<R> table,
                                                               R record,
                                                               Condition condition)
Update one record in a table
UPDATE [table] SET [modified values in record] WHERE [condition]

Specified by:
executeUpdateOne in interface FactoryOperations
Returns:
The number of updated records

executeDelete

public final <R extends TableRecord<R>> int executeDelete(Table<R> table)
Delete records from a table
DELETE FROM [table]

Specified by:
executeDelete in interface FactoryOperations
Returns:
The number of deleted records

executeDelete

public final <R extends TableRecord<R>,T> int executeDelete(Table<R> table,
                                                            Condition condition)
Delete records from a table
DELETE FROM [table] WHERE [condition]

Specified by:
executeDelete in interface FactoryOperations
Returns:
The number of deleted records

executeDeleteOne

public final <R extends TableRecord<R>> int executeDeleteOne(Table<R> table)
Delete one record in a table
DELETE FROM [table]

Specified by:
executeDeleteOne in interface FactoryOperations
Returns:
The number of deleted records

executeDeleteOne

public final <R extends TableRecord<R>,T> int executeDeleteOne(Table<R> table,
                                                               Condition condition)
Delete one record in a table
DELETE FROM [table] WHERE [condition]

Specified by:
executeDeleteOne in interface FactoryOperations
Returns:
The number of deleted records

getDataType

public static <T> DataType<T> getDataType(Class<? extends T> type)
Get the default data type for the Factory's underlying SQLDialect and a given Java type.

This is a convenience method for calling FieldTypeHelper.getDataType(SQLDialect, Class)

Type Parameters:
T - The generic type
Parameters:
type - The Java type
Returns:
The Factory's underlying default data type.

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2012. All Rights Reserved.