public class Factory extends Object implements FactoryOperations
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(...));
Factory
. For example:
import static org.jooq.impl.Factory.*;
public class Main {
public static void main(String[] args) {
new Factory(dialect).select(val("Hello"), inline("World"));
// Factory.val ^^^ ^^^^^^ Factory.inline
}
}
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.
Constructor and Description |
---|
Factory(Connection connection,
SQLDialect dialect)
Create a factory with a connection and a 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 a connection, a dialect and settings configured.
|
Factory(DataSource datasource,
SQLDialect dialect)
Create a factory with a data source and a dialect configured.
|
Factory(DataSource datasource,
SQLDialect dialect,
Settings settings)
Create a factory with a data source, a dialect and settings configured.
|
Factory(SQLDialect dialect)
Create a factory with a dialect configured.
|
Factory(SQLDialect dialect,
Settings settings)
Create a factory with a dialect and settings configured
Without a connection or data source, this factory cannot execute queries.
|
Modifier and Type | Method and Description |
---|---|
static <T extends Number> |
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> |
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).
|
Batch |
batchStore(Collection<? extends UpdatableRecord<?>> records)
Execute a set of
INSERT and UPDATE queries in
batch mode (with bind values). |
Batch |
batchStore(UpdatableRecord<?>... records)
Execute a set of
INSERT and UPDATE 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:
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:
RenderContext for JOOQ INTERNAL USE only. |
static <T extends Number> |
bitAnd(Field<T> field1,
Field<T> field2)
The bitwise and operator.
|
static <T extends Number> |
bitAnd(Field<T> value1,
T value2)
The bitwise and operator.
|
static <T extends Number> |
bitAnd(T value1,
Field<T> value2)
The bitwise and operator.
|
static <T extends Number> |
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> |
bitNand(Field<T> field1,
Field<T> field2)
The bitwise not and operator.
|
static <T extends Number> |
bitNand(Field<T> value1,
T value2)
The bitwise not and operator.
|
static <T extends Number> |
bitNand(T value1,
Field<T> value2)
The bitwise not and operator.
|
static <T extends Number> |
bitNand(T value1,
T value2)
The bitwise not and operator.
|
static <T extends Number> |
bitNor(Field<T> field1,
Field<T> field2)
The bitwise not or operator.
|
static <T extends Number> |
bitNor(Field<T> value1,
T value2)
The bitwise not or operator.
|
static <T extends Number> |
bitNor(T value1,
Field<T> value2)
The bitwise not or operator.
|
static <T extends Number> |
bitNor(T value1,
T value2)
The bitwise not or operator.
|
static <T extends Number> |
bitNot(Field<T> field)
The bitwise not operator.
|
static <T extends Number> |
bitNot(T value)
The bitwise not operator.
|
static <T extends Number> |
bitOr(Field<T> field1,
Field<T> field2)
The bitwise or operator.
|
static <T extends Number> |
bitOr(Field<T> value1,
T value2)
The bitwise or operator.
|
static <T extends Number> |
bitOr(T value1,
Field<T> value2)
The bitwise or operator.
|
static <T extends Number> |
bitOr(T value1,
T value2)
The bitwise or operator.
|
static <T extends Number> |
bitXNor(Field<T> field1,
Field<T> field2)
The bitwise not xor operator.
|
static <T extends Number> |
bitXNor(Field<T> value1,
T value2)
The bitwise not xor operator.
|
static <T extends Number> |
bitXNor(T value1,
Field<T> value2)
The bitwise not xor operator.
|
static <T extends Number> |
bitXNor(T value1,
T value2)
The bitwise not xor operator.
|
static <T extends Number> |
bitXor(Field<T> field1,
Field<T> field2)
The bitwise xor operator.
|
static <T extends Number> |
bitXor(Field<T> value1,
T value2)
The bitwise xor operator.
|
static <T extends Number> |
bitXor(T value1,
Field<T> value2)
The bitwise xor operator.
|
static <T extends Number> |
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> |
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> |
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 |
void |
commit()
Convenience method to access
Connection.commit()
Use this method only if you control the JDBC Connection wrapped
by this Configuration , and if that connection manages the current
transaction. |
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 Condition |
condition(String sql,
QueryPart... parts)
A custom SQL clause that can render arbitrary SQL elements.
|
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 <T> Field<T> |
connectByRoot(Field<T> field)
Retrieve the Oracle-specific
CONNECT_BY_ROOT pseudo-column
(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<?>... fields)
Get the count(distinct field1, field2) function
Some dialects support several expressions in the
COUNT(DISTINCT expr1, expr2) aggregate 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> |
currval(Sequence<T> sequence)
Convenience method to fetch the CURRVAL for a sequence directly from this
Factory 's underlying JDBC Connection |
static Field<Date> |
dateAdd(Date date,
Number interval)
Add an interval to a date
This translates into any dialect
|
static Field<Date> |
dateAdd(Field<Date> date,
Field<? extends Number> interval)
Add an interval to a date
This translates into any dialect
|
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> |
delete(Table<R> table)
Create a new DSL delete statement.
|
<R extends Record> |
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.
|
int |
execute(String sql,
QueryPart... parts)
Execute a new query holding plain SQL.
|
<R extends UpdatableRecord<R>> |
executeDelete(R record)
Delete a record from a table
DELETE FROM [table] WHERE [record is supplied record] |
<R extends TableRecord<R>,T> |
executeDelete(R record,
Condition condition)
Delete a record from a table
DELETE FROM [table] WHERE [condition] |
<R extends TableRecord<R>> |
executeDelete(Table<R> table)
Deprecated.
|
<R extends TableRecord<R>,T> |
executeDelete(Table<R> table,
Condition condition)
Deprecated.
|
<R extends TableRecord<R>> |
executeDeleteOne(Table<R> table)
Deprecated.
|
<R extends TableRecord<R>,T> |
executeDeleteOne(Table<R> table,
Condition condition)
Deprecated.
|
<R extends TableRecord<R>> |
executeInsert(R record)
Insert one record
This executes something like the following statement:
INSERT INTO [table] ... |
<R extends TableRecord<R>> |
executeInsert(Table<R> table,
R record)
Deprecated.
|
<R extends UpdatableRecord<R>> |
executeUpdate(R record)
Update a table
UPDATE [table] SET [modified values in record] WHERE [record is supplied record] |
<R extends TableRecord<R>,T> |
executeUpdate(R record,
Condition condition)
Update a table
UPDATE [table] SET [modified values in record] WHERE [condition] |
<R extends TableRecord<R>> |
executeUpdate(Table<R> table,
R record)
Deprecated.
|
<R extends TableRecord<R>,T> |
executeUpdate(Table<R> table,
R record,
Condition condition)
Deprecated.
|
<R extends TableRecord<R>> |
executeUpdateOne(Table<R> table,
R record)
Deprecated.
|
<R extends TableRecord<R>,T> |
executeUpdateOne(Table<R> table,
R record,
Condition condition)
Deprecated.
|
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)
|
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.
|
Result<Record> |
fetch(String sql,
QueryPart... parts)
Execute a new query holding plain SQL.
|
<R extends Record> |
fetch(Table<R> table)
Execute and return all records for
SELECT * FROM [table]
The result and its contained records are attached to this
Configuration by default. |
<R extends Record> |
fetch(Table<R> table,
Condition condition)
Execute and return all records for
SELECT * FROM [table] WHERE [condition]
The result and its contained records are attached to this
Configuration by default. |
<R extends Record> |
fetchAny(Table<R> table)
Execute and return zero or one record for
SELECT * FROM [table] LIMIT 1
The resulting record is attached to this Configuration by
default. |
Result<Record> |
fetchFromCSV(String string)
Fetch all data from a CSV string.
|
Result<Record> |
fetchFromCSV(String string,
char delimiter)
Fetch all data from a CSV string.
|
Cursor<Record> |
fetchLazy(ResultSet rs)
|
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.
|
Cursor<Record> |
fetchLazy(String sql,
QueryPart... parts)
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.
|
List<Result<Record>> |
fetchMany(String sql,
QueryPart... parts)
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.
|
Record |
fetchOne(String sql,
QueryPart... parts)
Execute a new query holding plain SQL.
|
<R extends Record> |
fetchOne(Table<R> table)
Execute and return zero or one record for
SELECT * FROM [table]
The resulting record is attached to this Configuration by
default. |
<R extends Record> |
fetchOne(Table<R> table,
Condition condition)
Execute and return zero or one record for
SELECT * FROM [table] WHERE [condition]
The resulting record is attached to this Configuration by
default. |
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> Field<T> |
fieldByName(Class<T> type,
String... qualifiedName)
Create a qualified field, given its (qualified) field name.
|
static <T> Field<T> |
fieldByName(DataType<T> type,
String... qualifiedName)
Create a qualified field, given its (qualified) field name.
|
static Field<Object> |
fieldByName(String... qualifiedName)
Create a qualified field, given its (qualified) field name.
|
static <T> WindowIgnoreNullsStep<T> |
firstValue(Field<T> field)
The
first_value(field) over ([analytic clause]) function. |
static <T extends Number> |
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> |
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. |
boolean |
getAutoCommit()
Convenience method to access
Connection.getAutoCommit()
Use this method only if you control the JDBC Connection wrapped
by this Configuration , and if that connection manages the current
transaction. |
Connection |
getConnection()
Retrieve the configured connection
If you configured a data source for this
Configuration (see
Configuration.setDataSource(DataSource) ), then this may initialise a new
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) . |
DataSource |
getDataSource()
Retrieve the configured data source
|
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
|
int |
getHoldability()
Convenience method to access
Connection.getHoldability()
Use this method only if you control the JDBC Connection wrapped
by this Configuration , and if that connection manages the current
transaction. |
SchemaMapping |
getSchemaMapping()
Deprecated.
|
Settings |
getSettings()
Retrieve the runtime configuration settings
|
int |
getTransactionIsolation()
Convenience method to access
Connection.getTransactionIsolation()
Use this method only if you control the JDBC Connection wrapped
by this Configuration , and if that connection manages the current
transaction. |
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 |
static Param<String> |
inline(char character)
Create a bind value, that is always inlined.
|
static Param<String> |
inline(Character character)
Create a bind value, that is always inlined.
|
static Param<String> |
inline(CharSequence character)
Create a bind value, that is always inlined.
|
static <T> Param<T> |
inline(Object value,
Class<? extends T> type)
Create a bind value, that is always inlined.
|
static <T> Param<T> |
inline(Object value,
DataType<T> type)
Create a bind value, that is always inlined.
|
static <T> Param<T> |
inline(Object value,
Field<T> field)
Create a bind value, that is always inlined.
|
static <T> Param<T> |
inline(T value)
Create a bind value, that is always inlined.
|
<R extends Record> |
insertInto(Table<R> into)
Create a new DSL insert statement.
|
<R extends Record> |
insertInto(Table<R> into,
Collection<? extends Field<?>> fields)
Create a new DSL insert statement.
|
<R extends Record> |
insertInto(Table<R> into,
Field<?>... fields)
Create a new DSL insert statement.
|
<R extends Record> |
insertInto(Table<R> into,
Select<?> select)
Deprecated.
|
<R extends Record> |
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)
Deprecated.
- 2.3.0 - Use
field(String, Class) , or
inline(Object, Class) instead. |
static <T> Field<T> |
literal(Object literal,
DataType<T> type)
Deprecated.
- 2.3.0 - Use
field(String, DataType) , or
inline(Object, DataType) instead. |
static <T> Field<T> |
literal(T literal)
Deprecated.
- 2.3.0 - Use
field(String) , or
inline(Object) instead. |
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>> |
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])
In SQLDialect.SQLITE , this is simulated as such:
replace(replace(substr(quote(zeroblob(([length] + 1) / 2)), 3, ([length] - length([field]))), '''', ''), '0', [character]) || [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> field)
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)
|
<R extends Record> |
mergeInto(Table<R> table)
Create a new DSL SQL standard MERGE statement.
|
<R extends Record> |
mergeInto(Table<R> table,
Collection<? extends Field<?>> fields)
Create a new DSL merge statement (H2-specific syntax)
|
<R extends Record> |
mergeInto(Table<R> table,
Field<?>... fields)
Create a new DSL merge statement (H2-specific syntax)
This statement is available from DSL syntax only.
|
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 |
static Name |
name(String... qualifiedName)
Create a new SQL identifier using a qualified name.
|
<R extends TableRecord<R>> |
newRecord(Table<R> table)
Create a new
Record that can be inserted into the corresponding
table. |
<R extends TableRecord<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>> |
newRecord(UDT<R> type)
Create a new
UDTRecord . |
<T extends Number> |
nextval(Sequence<T> sequence)
Convenience method to fetch the NEXTVAL for a sequence directly from this
Factory 's underlying JDBC Connection |
static Condition |
not(Condition condition)
Invert a condition
This is the same as calling
Condition.not() |
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
|
protected static Field<?>[] |
nullSafe(Field<?>... fields)
Null-safety of a field
|
protected static <T> Field<T> |
nullSafe(Field<T> field)
Null-safety of a field
|
protected static <T> DataType<T> |
nullSafeDataType(Field<T> field)
Get a default data type if a field is null
|
static <T> Field<T> |
nvl(Field<T> value,
Field<T> defaultValue)
|
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.
|
Query |
query(String sql,
QueryPart... parts)
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. |
static AggregateFunction<BigDecimal> |
regrAvgX(Field<? extends Number> y,
Field<? extends Number> x)
Get the
REGR_AVGX linear regression function
The linear regression functions fit an ordinary-least-squares regression
line to a set of number pairs. |
static AggregateFunction<BigDecimal> |
regrAvgY(Field<? extends Number> y,
Field<? extends Number> x)
Get the
REGR_AVGY linear regression function
The linear regression functions fit an ordinary-least-squares regression
line to a set of number pairs. |
static AggregateFunction<BigDecimal> |
regrCount(Field<? extends Number> y,
Field<? extends Number> x)
Get the
REGR_COUNT linear regression function
The linear regression functions fit an ordinary-least-squares regression
line to a set of number pairs. |
static AggregateFunction<BigDecimal> |
regrIntercept(Field<? extends Number> y,
Field<? extends Number> x)
Get the
REGR_INTERCEPT linear regression function
The linear regression functions fit an ordinary-least-squares regression
line to a set of number pairs. |
static AggregateFunction<BigDecimal> |
regrR2(Field<? extends Number> y,
Field<? extends Number> x)
Get the
REGR_R2 linear regression function
The linear regression functions fit an ordinary-least-squares regression
line to a set of number pairs. |
static AggregateFunction<BigDecimal> |
regrSlope(Field<? extends Number> y,
Field<? extends Number> x)
Get the
REGR_SLOPE linear regression function
The linear regression functions fit an ordinary-least-squares regression
line to a set of number pairs. |
static AggregateFunction<BigDecimal> |
regrSXX(Field<? extends Number> y,
Field<? extends Number> x)
Get the
REGR_SXX linear regression function
The linear regression functions fit an ordinary-least-squares regression
line to a set of number pairs. |
static AggregateFunction<BigDecimal> |
regrSXY(Field<? extends Number> y,
Field<? extends Number> x)
Get the
REGR_SXY linear regression function
The linear regression functions fit an ordinary-least-squares regression
line to a set of number pairs. |
static AggregateFunction<BigDecimal> |
regrSYY(Field<? extends Number> y,
Field<? extends Number> x)
Get the
REGR_SYY linear regression function
The linear regression functions fit an ordinary-least-squares regression
line to a set of number pairs. |
void |
releaseSavepoint(Savepoint savepoint)
Convenience method to access
Connection.releaseSavepoint(Savepoint)
Use this method only if you control the JDBC Connection wrapped
by this Configuration , and if that connection manages the current
transaction. |
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:
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])
In SQLDialect.SQLITE , this is simulated as such:
replace(substr(quote(zeroblob(([count] + 1) / 2)), 3, [count]), '0', [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.
|
ResultQuery<Record> |
resultQuery(String sql,
QueryPart... parts)
Create a new query holding plain SQL.
|
void |
rollback()
Convenience method to access
Connection.rollback()
Use this method only if you control the JDBC Connection wrapped
by this Configuration , and if that connection manages the current
transaction. |
void |
rollback(Savepoint savepoint)
Convenience method to access
Connection.rollback(Savepoint)
Use this method only if you control the JDBC Connection wrapped
by this Configuration , and if that connection manages the current
transaction. |
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> |
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> |
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> |
round(T value)
Get rounded value of a numeric field: round(field)
|
static <T extends Number> |
round(T value,
int decimals)
Get rounded value of a numeric field: round(field, decimals)
|
static RowN |
row(Field<?>... values)
Create a row value expression of degree
N > 8
Note: Not all databases support row value expressions, but many row value
expression operations can be simulated on all databases. |
static <T1> Row1<T1> |
row(Field<T1> t1)
Create a row value expression of degree
1
Note: Not all databases support row value expressions, but many row value
expression operations can be simulated on all databases. |
static <T1,T2> Row2<T1,T2> |
row(Field<T1> t1,
Field<T2> t2)
Create a row value expression of degree
2
Note: Not all databases support row value expressions, but many row value
expression operations can be simulated on all databases. |
static <T1,T2,T3> Row3<T1,T2,T3> |
row(Field<T1> t1,
Field<T2> t2,
Field<T3> t3)
Create a row value expression of degree
3
Note: Not all databases support row value expressions, but many row value
expression operations can be simulated on all databases. |
static <T1,T2,T3,T4> |
row(Field<T1> t1,
Field<T2> t2,
Field<T3> t3,
Field<T4> t4)
Create a row value expression of degree
4
Note: Not all databases support row value expressions, but many row value
expression operations can be simulated on all databases. |
static <T1,T2,T3,T4,T5> |
row(Field<T1> t1,
Field<T2> t2,
Field<T3> t3,
Field<T4> t4,
Field<T5> t5)
Create a row value expression of degree
5
Note: Not all databases support row value expressions, but many row value
expression operations can be simulated on all databases. |
static <T1,T2,T3,T4,T5,T6> |
row(Field<T1> t1,
Field<T2> t2,
Field<T3> t3,
Field<T4> t4,
Field<T5> t5,
Field<T6> t6)
Create a row value expression of degree
6
Note: Not all databases support row value expressions, but many row value
expression operations can be simulated on all databases. |
static <T1,T2,T3,T4,T5,T6,T7> |
row(Field<T1> t1,
Field<T2> t2,
Field<T3> t3,
Field<T4> t4,
Field<T5> t5,
Field<T6> t6,
Field<T7> t7)
Create a row value expression of degree
7
Note: Not all databases support row value expressions, but many row value
expression operations can be simulated on all databases. |
static <T1,T2,T3,T4,T5,T6,T7,T8> |
row(Field<T1> t1,
Field<T2> t2,
Field<T3> t3,
Field<T4> t4,
Field<T5> t5,
Field<T6> t6,
Field<T7> t7,
Field<T8> t8)
Create a row value expression of degree
8
Note: Not all databases support row value expressions, but many row value
expression operations can be simulated on all databases. |
static RowN |
row(Object... values)
Create a row value expression of degree
N > 8
Note: Not all databases support row value expressions, but many row value
expression operations can be simulated on all databases. |
static <T1> Row1<T1> |
row(T1 t1)
Create a row value expression of degree
1
Note: Not all databases support row value expressions, but many row value
expression operations can be simulated on all databases. |
static <T1,T2> Row2<T1,T2> |
row(T1 t1,
T2 t2)
Create a row value expression of degree
2
Note: Not all databases support row value expressions, but many row value
expression operations can be simulated on all databases. |
static <T1,T2,T3> Row3<T1,T2,T3> |
row(T1 t1,
T2 t2,
T3 t3)
Create a row value expression of degree
3
Note: Not all databases support row value expressions, but many row value
expression operations can be simulated on all databases. |
static <T1,T2,T3,T4> |
row(T1 t1,
T2 t2,
T3 t3,
T4 t4)
Create a row value expression of degree
4
Note: Not all databases support row value expressions, but many row value
expression operations can be simulated on all databases. |
static <T1,T2,T3,T4,T5> |
row(T1 t1,
T2 t2,
T3 t3,
T4 t4,
T5 t5)
Create a row value expression of degree
5
Note: Not all databases support row value expressions, but many row value
expression operations can be simulated on all databases. |
static <T1,T2,T3,T4,T5,T6> |
row(T1 t1,
T2 t2,
T3 t3,
T4 t4,
T5 t5,
T6 t6)
Create a row value expression of degree
6
Note: Not all databases support row value expressions, but many row value
expression operations can be simulated on all databases. |
static <T1,T2,T3,T4,T5,T6,T7> |
row(T1 t1,
T2 t2,
T3 t3,
T4 t4,
T5 t5,
T6 t6,
T7 t7)
Create a row value expression of degree
7
Note: Not all databases support row value expressions, but many row value
expression operations can be simulated on all databases. |
static <T1,T2,T3,T4,T5,T6,T7,T8> |
row(T1 t1,
T2 t2,
T3 t3,
T4 t4,
T5 t5,
T6 t6,
T7 t7,
T8 t8)
Create a row value expression of degree
8
Note: Not all databases support row value expressions, but many row value
expression operations can be simulated on all databases. |
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])))
In SQLDialect.SQLITE , this is simulated as such:
[field] || replace(replace(substr(quote(zeroblob(([length] + 1) / 2)), 3, ([length] - length([field]))), '''', ''), '0', [character]) |
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 Schema |
schemaByName(String name)
Create a qualified schema, given its schema name
This constructs a schema reference given the schema's qualified name.
|
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);
|
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> |
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);
|
SelectQuery |
selectQuery()
Create a new
SelectQuery |
<R extends Record> |
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);
|
void |
setAutoCommit(boolean autoCommit)
Convenience method to access
Connection.setAutoCommit(boolean)
Use this method only if you control the JDBC Connection wrapped
by this Configuration , and if that connection manages the current
transaction. |
void |
setConnection(Connection connection)
Set the configured connection
If you provide a JDBC connection to a jOOQ Factory, jOOQ will use that
connection for creating statements, but it will never call any of these
methods:
Connection.commit()
Connection.rollback()
Connection.close()
Use this constructor if you want to handle transactions directly on the
connection. |
Object |
setData(String key,
Object value)
Set some custom data to this
Configuration
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. |
void |
setDataSource(DataSource datasource)
Set the configured data source
If you provide a JDBC data source to a jOOQ Factory, jOOQ will use that
data source for initialising connections, and creating statements.
|
void |
setHoldability(int holdability)
Convenience method to access
Connection.setHoldability(int)
Use this method only if you control the JDBC Connection wrapped
by this Configuration , and if that connection manages the current
transaction. |
Savepoint |
setSavepoint()
Convenience method to access
Connection.setSavepoint()
Use this method only if you control the JDBC Connection wrapped
by this Configuration , and if that connection manages the current
transaction. |
Savepoint |
setSavepoint(String name)
Convenience method to access
Connection.setSavepoint(String)
Use this method only if you control the JDBC Connection wrapped
by this Configuration , and if that connection manages the current
transaction. |
void |
setTransactionIsolation(int level)
Convenience method to access
Connection.setTransactionIsolation(int)
Use this method only if you control the JDBC Connection wrapped
by this Configuration , and if that connection manages the current
transaction. |
static <T extends Number> |
shl(Field<T> field1,
Field<T> field2)
The bitwise left shift operator.
|
static <T extends Number> |
shl(Field<T> value1,
T value2)
The bitwise left shift operator.
|
static <T extends Number> |
shl(T value1,
Field<T> value2)
The bitwise left shift operator.
|
static <T extends Number> |
shl(T value1,
T value2)
The bitwise left shift operator.
|
static <T extends Number> |
shr(Field<T> field1,
Field<T> field2)
The bitwise right shift operator.
|
static <T extends Number> |
shr(Field<T> value1,
T value2)
The bitwise right shift operator.
|
static <T extends Number> |
shr(T value1,
Field<T> value2)
The bitwise right shift operator.
|
static <T extends Number> |
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)
|
static AggregateFunction<BigDecimal> |
stddevSamp(Field<? extends Number> field)
Get the sample standard deviation of a numeric field: stddev_samp(field)
|
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(Select<R> select)
A synonym for
TableLike.asTable() . |
static Table<Record> |
table(String sql)
A custom SQL clause that can render arbitrary table expressions.
|
static Table<Record> |
table(String sql,
Object... bindings)
A custom SQL clause that can render arbitrary table expressions.
|
static Table<Record> |
table(String sql,
QueryPart... parts)
A custom SQL clause that can render arbitrary table expressions.
|
static Table<Record> |
tableByName(String... qualifiedName)
Create a qualified table, given its table name
This constructs a table reference given the table's qualified name. jOOQ
will render the table name according to your
Settings.getRenderNameStyle() settings. |
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<Timestamp> |
timestampAdd(Field<Timestamp> timestamp,
Field<? extends Number> interval)
Add an interval to a timestamp
This translates into any dialect
|
static Field<Timestamp> |
timestampAdd(Timestamp timestamp,
Number interval)
Add an interval to a timestamp
This translates into any dialect
|
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 |
static <T extends Number> |
trunc(Field<T> number,
Field<Integer> decimals)
Truncate a number to a given number of decimals
This function truncates
number to the amount of decimals
specified in decimals . |
static <T extends Number> |
trunc(Field<T> number,
int decimals)
Truncate a number to a given number of decimals
|
static <T extends Number> |
trunc(T number)
Truncate a number to a given number of decimals
|
static <T extends Number> |
trunc(T number,
Field<Integer> decimals)
Truncate a number to a given number of decimals
|
static <T extends Number> |
trunc(T number,
int decimals)
Truncate a number to a given number of decimals
|
<R extends Record> |
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> |
update(Table<R> table)
Create a new DSL update statement.
|
<R extends Record> |
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, Class) 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, DataType) 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, Field) 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)
|
static AggregateFunction<BigDecimal> |
varSamp(Field<? extends Number> field)
Get the sample variance of a numeric field: var_samp(field)
|
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. |
public Factory(Connection connection, SQLDialect dialect)
If you provide a JDBC connection to a jOOQ Factory, jOOQ will use that connection for creating statements, but it will never call any of these methods:
Use this constructor if you want to handle transactions directly on the connection.connection
- The connection to use with objects created from this
factorydialect
- The dialect to use with objects created from this factorypublic Factory(DataSource datasource, SQLDialect dialect)
If you provide a JDBC data source to a jOOQ Factory, jOOQ will use that data source for initialising connections, and creating statements.
Use this constructor if you want to run distributed transactions, such as
javax.transaction.UserTransaction
. If you provide jOOQ
factories with a data source, jOOQ will close()
all connections after query execution in order to return the
connection to the connection pool. If you do not use distributed
transactions, this will produce driver-specific behaviour at the end of
query execution at close()
invocation (e.g. a transaction
rollback). Use Factory(Connection, SQLDialect)
instead, to
control the connection's lifecycle.
datasource
- The data source to use with objects created from this
factorydialect
- The dialect to use with objects created from this factorypublic Factory(SQLDialect dialect)
Without a connection or data source, this factory cannot execute queries. Use it to render SQL only.
dialect
- The dialect to use with objects created from this factory@Deprecated public Factory(Connection connection, SQLDialect dialect, SchemaMapping mapping)
Factory(Connection, SQLDialect, Settings)
insteadIf you provide a JDBC connection to a jOOQ Factory, jOOQ will use that connection for creating statements, but it will never call any of these methods:
Use this constructor if you want to handle transactions directly on the connection.connection
- The connection to use with objects created from this
factorydialect
- The dialect to use with objects created from this factorymapping
- The schema mapping to use with objects created from this
factorypublic Factory(Connection connection, SQLDialect dialect, Settings settings)
If you provide a JDBC connection to a jOOQ Factory, jOOQ will use that connection for creating statements, but it will never call any of these methods:
Use this constructor if you want to handle transactions directly on the connection.connection
- The connection to use with objects created from this
factorydialect
- The dialect to use with objects created from this factorysettings
- The runtime settings to apply to objects created from
this factorypublic Factory(DataSource datasource, SQLDialect dialect, Settings settings)
If you provide a JDBC data source to a jOOQ Factory, jOOQ will use that data source for initialising connections, and creating statements.
Use this constructor if you want to run distributed transactions, such as
javax.transaction.UserTransaction
. If you provide jOOQ
factories with a data source, jOOQ will close()
all connections after query execution in order to return the
connection to the connection pool. If you do not use distributed
transactions, this will produce driver-specific behaviour at the end of
query execution at close()
invocation (e.g. a transaction
rollback). Use Factory(Connection, SQLDialect, Settings)
instead, to control the connection's lifecycle.
datasource
- The data source to use with objects created from this
factorydialect
- The dialect to use with objects created from this factorysettings
- The runtime settings to apply to objects created from
this factorypublic Factory(SQLDialect dialect, Settings settings)
Without a connection or data source, this factory cannot execute queries. Use it to render SQL only.
dialect
- The dialect to use with objects created from this factorysettings
- The runtime settings to apply to objects created from
this factorypublic final SQLDialect getDialect()
getDialect
in interface Configuration
public final DataSource getDataSource()
getDataSource
in interface Configuration
public void setDataSource(DataSource datasource)
If you provide a JDBC data source to a jOOQ Factory, jOOQ will use that data source for initialising connections, and creating statements.
Use data sources if you want to run distributed transactions, such as
javax.transaction.UserTransaction
. If you provide jOOQ
factories with a data source, jOOQ will close()
all connections after query execution in order to return the
connection to the connection pool. If you do not use distributed
transactions, this will produce driver-specific behaviour at the end of
query execution at close()
invocation (e.g. a transaction
rollback). Use Configuration.setConnection(Connection)
instead, to control the
connection's lifecycle.
setDataSource
in interface Configuration
public final Connection getConnection()
If you configured a data source for this Configuration
(see
Configuration.setDataSource(DataSource)
), then this may initialise a new
connection.
getConnection
in interface Configuration
public final void setConnection(Connection connection)
If you provide a JDBC connection to a jOOQ Factory, jOOQ will use that connection for creating statements, but it will never call any of these methods:
Use this constructor if you want to handle transactions directly on the connection.setConnection
in interface Configuration
@Deprecated public final SchemaMapping getSchemaMapping()
getSchemaMapping
in interface Configuration
public final Settings getSettings()
getSettings
in interface Configuration
public final Map<String,Object> getData()
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.
getData
in interface Configuration
null
ExecuteListener
public final Object getData(String key)
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.
getData
in interface Configuration
key
- A key to identify the custom datanull
if no such data is contained
in this Configuration
ExecuteListener
public final Object setData(String key, Object value)
Configuration
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.
setData
in interface Configuration
key
- A key to identify the custom datavalue
- The custom data or null
to unset the custom
datanull
if no data
was previously set for the given keyExecuteListener
public final void commit() throws DataAccessException
Connection.commit()
Use this method only if you control the JDBC Connection
wrapped
by this Configuration
, and if that connection manages the current
transaction. If your transaction is operated on a distributed
javax.transaction.UserTransaction
, for instance, this method
will not work.
commit
in interface FactoryOperations
DataAccessException
Configuration.setConnection(Connection)
,
Configuration.setDataSource(DataSource)
public final void rollback() throws DataAccessException
Connection.rollback()
Use this method only if you control the JDBC Connection
wrapped
by this Configuration
, and if that connection manages the current
transaction. If your transaction is operated on a distributed
javax.transaction.UserTransaction
, for instance, this method
will not work.
rollback
in interface FactoryOperations
DataAccessException
Configuration.setConnection(Connection)
,
Configuration.setDataSource(DataSource)
public final void rollback(Savepoint savepoint) throws DataAccessException
Connection.rollback(Savepoint)
Use this method only if you control the JDBC Connection
wrapped
by this Configuration
, and if that connection manages the current
transaction. If your transaction is operated on a distributed
javax.transaction.UserTransaction
, for instance, this method
will not work.
rollback
in interface FactoryOperations
DataAccessException
Configuration.setConnection(Connection)
,
Configuration.setDataSource(DataSource)
public final Savepoint setSavepoint() throws DataAccessException
Connection.setSavepoint()
Use this method only if you control the JDBC Connection
wrapped
by this Configuration
, and if that connection manages the current
transaction. If your transaction is operated on a distributed
javax.transaction.UserTransaction
, for instance, this method
will not work.
setSavepoint
in interface FactoryOperations
DataAccessException
Configuration.setConnection(Connection)
,
Configuration.setDataSource(DataSource)
public final Savepoint setSavepoint(String name) throws DataAccessException
Connection.setSavepoint(String)
Use this method only if you control the JDBC Connection
wrapped
by this Configuration
, and if that connection manages the current
transaction. If your transaction is operated on a distributed
javax.transaction.UserTransaction
, for instance, this method
will not work.
setSavepoint
in interface FactoryOperations
DataAccessException
Configuration.setConnection(Connection)
,
Configuration.setDataSource(DataSource)
public final void releaseSavepoint(Savepoint savepoint) throws DataAccessException
Connection.releaseSavepoint(Savepoint)
Use this method only if you control the JDBC Connection
wrapped
by this Configuration
, and if that connection manages the current
transaction. If your transaction is operated on a distributed
javax.transaction.UserTransaction
, for instance, this method
will not work.
releaseSavepoint
in interface FactoryOperations
DataAccessException
Configuration.setConnection(Connection)
,
Configuration.setDataSource(DataSource)
public final void setAutoCommit(boolean autoCommit) throws DataAccessException
Connection.setAutoCommit(boolean)
Use this method only if you control the JDBC Connection
wrapped
by this Configuration
, and if that connection manages the current
transaction. If your transaction is operated on a distributed
javax.transaction.UserTransaction
, for instance, this method
will not work.
setAutoCommit
in interface FactoryOperations
DataAccessException
Configuration.setConnection(Connection)
,
Configuration.setDataSource(DataSource)
public final boolean getAutoCommit() throws DataAccessException
Connection.getAutoCommit()
Use this method only if you control the JDBC Connection
wrapped
by this Configuration
, and if that connection manages the current
transaction. If your transaction is operated on a distributed
javax.transaction.UserTransaction
, for instance, this method
will not work.
getAutoCommit
in interface FactoryOperations
DataAccessException
Configuration.setConnection(Connection)
,
Configuration.setDataSource(DataSource)
public final void setHoldability(int holdability) throws DataAccessException
Connection.setHoldability(int)
Use this method only if you control the JDBC Connection
wrapped
by this Configuration
, and if that connection manages the current
transaction. If your transaction is operated on a distributed
javax.transaction.UserTransaction
, for instance, this method
will not work.
setHoldability
in interface FactoryOperations
DataAccessException
Configuration.setConnection(Connection)
,
Configuration.setDataSource(DataSource)
public final int getHoldability() throws DataAccessException
Connection.getHoldability()
Use this method only if you control the JDBC Connection
wrapped
by this Configuration
, and if that connection manages the current
transaction. If your transaction is operated on a distributed
javax.transaction.UserTransaction
, for instance, this method
will not work.
getHoldability
in interface FactoryOperations
DataAccessException
Configuration.setConnection(Connection)
,
Configuration.setDataSource(DataSource)
public final void setTransactionIsolation(int level) throws DataAccessException
Connection.setTransactionIsolation(int)
Use this method only if you control the JDBC Connection
wrapped
by this Configuration
, and if that connection manages the current
transaction. If your transaction is operated on a distributed
javax.transaction.UserTransaction
, for instance, this method
will not work.
setTransactionIsolation
in interface FactoryOperations
DataAccessException
Configuration.setConnection(Connection)
,
Configuration.setDataSource(DataSource)
public final int getTransactionIsolation() throws DataAccessException
Connection.getTransactionIsolation()
Use this method only if you control the JDBC Connection
wrapped
by this Configuration
, and if that connection manages the current
transaction. If your transaction is operated on a distributed
javax.transaction.UserTransaction
, for instance, this method
will not work.
getTransactionIsolation
in interface FactoryOperations
DataAccessException
Configuration.setConnection(Connection)
,
Configuration.setDataSource(DataSource)
public final RenderContext renderContext()
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. Avoid referencing it directly
public final String render(QueryPart part)
This is the same as calling renderContext().render(part)
render
in interface FactoryOperations
part
- The QueryPart
to be renderedpublic final String renderNamedParams(QueryPart part)
This is the same as calling
renderContext().namedParams(true).render(part)
renderNamedParams
in interface FactoryOperations
part
- The QueryPart
to be renderedpublic final String renderInlined(QueryPart part)
This is the same as calling
renderContext().inline(true).render(part)
renderInlined
in interface FactoryOperations
part
- The QueryPart
to be renderedpublic final BindContext bindContext(PreparedStatement stmt)
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. Avoid referencing it directly
public final int bind(QueryPart part, PreparedStatement stmt)
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. Avoid referencing it directly
public final void attach(Attachable... attachables)
Factory
to some attachablesattach
in interface FactoryOperations
public final void attach(Collection<Attachable> attachables)
Factory
to some attachablesattach
in interface FactoryOperations
public final <R extends TableRecord<R>> LoaderOptionsStep<R> loadInto(Table<R> table)
Loader
object to load data from a CSV or XML
sourceloadInto
in interface FactoryOperations
public static <R extends Record> Table<R> table(Select<R> select)
TableLike.asTable()
. It might look a bit more fluent
like this, to some usersTableLike.asTable()
@Support public static Table<?> table(List<?> list)
unnest(List)
unnest(List)
@Support public static Table<?> table(Object[] array)
unnest(Object[])
unnest(Object[])
@Support(value=ORACLE) public static Table<?> table(ArrayRecord<?> array)
unnest(ArrayRecord)
unnest(ArrayRecord)
@Support(value={H2,HSQLDB,POSTGRES,ORACLE}) public static Table<?> table(Field<?> cursor)
unnest(Field)
unnest(Field)
@Support public static Table<?> unnest(List<?> list)
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.
@Support public static Table<?> unnest(Object[] array)
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.
@Support(value=ORACLE) public static Table<?> unnest(ArrayRecord<?> array)
This wraps the argument array in a TABLE
function for
Oracle. Currently, only Oracle knows typed arrays
@Support(value={H2,HSQLDB,POSTGRES,ORACLE}) public static Table<?> unnest(Field<?> cursor)
Result
: For CURSOR
or REF CURSOR
fields, typically fetched from stored functions or from nested tablesArrayRecord
: For Oracle-style VARRAY
types.Object
[]: Array types, for other RDBMS's ARRAY types (e.g.
H2, HSQLDB, and Postgres)Object
: Any other type that jOOQ will try to convert in an
array first, before converting that array into a table
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.
public static Name name(String... qualifiedName)
Use this method to construct syntax-safe, SQL-injection-safe SQL
identifiers for use in plain SQL where QueryPart
objects are
accepted. For instance, this can be used with any of these methods:
field(String, QueryPart...)
field(String, Class, QueryPart...)
field(String, DataType, QueryPart...)
An example:
// This qualified name here
name("book", "title");
// ... will render this SQL on SQL Server with RenderNameStyle.QUOTED set
[book].[title]
qualifiedName
- The SQL identifier's qualified name partsQueryPart
that will render the SQL identifier@Support public static Schema schemaByName(String name)
This constructs a schema reference given the schema's qualified name.
jOOQ will render the schema name according to your
Settings.getRenderNameStyle()
settings. Choose
RenderNameStyle.QUOTED
to prevent syntax errors and/or SQL
injection.
Example:
// This schema...
schemaByName("MY_SCHEMA");
// ... will render this SQL on SQL Server with RenderNameStyle.QUOTED set
[MY_SCHEMA]
name
- The schema's reference name.name
@Support public static Table<Record> table(String sql)
A plain SQL table 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!
sql
- The SQL@Support public static Table<Record> table(String sql, Object... bindings)
A plain SQL table 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!
sql
- The SQL@Support public static Table<Record> table(String sql, QueryPart... parts)
A plain SQL table 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 {0}";
QueryPart[] parts = new QueryPart[] { USER_TABLES.OWNER.equal("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!
sql
- The SQL clause, containing {numbered placeholders} where query
parts can be injectedparts
- The QueryPart
objects that are rendered at the
{numbered placeholder} locations@Support public static Table<Record> tableByName(String... qualifiedName)
This constructs a table reference given the table's qualified name. jOOQ
will render the table name according to your
Settings.getRenderNameStyle()
settings. Choose
RenderNameStyle.QUOTED
to prevent syntax errors and/or SQL
injection.
Example:
// This table...
tableByName("MY_SCHEMA", "MY_TABLE");
// ... will render this SQL on SQL Server with RenderNameStyle.QUOTED set
[MY_SCHEMA].[MY_TABLE]
qualifiedName
- The various parts making up your table's reference
name.tableName
public static Field<Object> field(String sql, QueryPart... parts)
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:
field("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! One way to escape
literals is to use name(String...)
and similar methods
sql
- The SQL clause, containing {numbered placeholders} where query
parts can be injectedparts
- The QueryPart
objects that are rendered at the
{numbered placeholder} locationspublic static <T> Field<T> field(String sql, Class<T> type, QueryPart... parts)
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:
field("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! One way to escape
literals is to use name(String...)
and similar methods
sql
- The SQL clause, containing {numbered placeholders} where query
parts can be injectedtype
- The field typeparts
- The QueryPart
objects that are rendered at the
{numbered placeholder} locationspublic static <T> Field<T> field(String sql, DataType<T> type, QueryPart... parts)
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:
field("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! One way to escape
literals is to use name(String...)
and similar methods
sql
- The SQL clause, containing {numbered placeholders} where query
parts can be injectedtype
- The field typeparts
- The QueryPart
objects that are rendered at the
{numbered placeholder} locations@Support public static Field<Object> field(String 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!
sql
- The SQL@Support public static Field<Object> field(String sql, Object... bindings)
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!
sql
- The SQLbindings
- The bindings for the field@Support public static <T> Field<T> field(String sql, Class<T> type)
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!
sql
- The SQLtype
- The field type@Support public static <T> Field<T> field(String sql, Class<T> type, Object... bindings)
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!
sql
- The SQLtype
- The field typebindings
- The bindings for the field@Support public static <T> Field<T> field(String sql, DataType<T> type)
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!
sql
- The SQLtype
- The field type@Support public static <T> Field<T> field(String sql, DataType<T> type, Object... bindings)
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!
sql
- The SQLtype
- The field typebindings
- The bindings for the field@Support public static Field<Object> fieldByName(String... qualifiedName)
This constructs a field reference given the field's qualified name. jOOQ
will render the field name according to your
Settings.getRenderNameStyle()
settings. Choose
RenderNameStyle.QUOTED
to prevent syntax errors and/or SQL
injection.
Example:
// This field...
fieldByName("MY_SCHEMA", "MY_TABLE", "MY_FIELD");
// ... will render this SQL on SQL Server with RenderNameStyle.QUOTED set
[MY_SCHEMA].[MY_TABLE].[MY_FIELD]
Another example:
create.select(field("length({1})", Integer.class, fieldByName("TITLE")))
.from(tableByName("T_BOOK"))
.fetch();
// ... will execute this SQL on SQL Server:
select length([TITLE]) from [T_BOOK]
qualifiedName
- The various parts making up your field's reference
name.fieldName
@Support public static <T> Field<T> fieldByName(Class<T> type, String... qualifiedName)
This constructs a field reference given the field's qualified name. jOOQ
will render the field name according to your
Settings.getRenderNameStyle()
settings. Choose
RenderNameStyle.QUOTED
to prevent syntax errors and/or SQL
injection.
Example:
// This field...
fieldByName("MY_SCHEMA", "MY_TABLE", "MY_FIELD");
// ... will render this SQL on SQL Server with RenderNameStyle.QUOTED set
[MY_SCHEMA].[MY_TABLE].[MY_FIELD]
Another example:
create.select(field("length({1})", Integer.class, fieldByName("TITLE")))
.from(tableByName("T_BOOK"))
.fetch();
// ... will execute this SQL on SQL Server:
select length([TITLE]) from [T_BOOK]
qualifiedName
- The various parts making up your field's reference
name.type
- The type of the returned fieldfieldName
@Support public static <T> Field<T> fieldByName(DataType<T> type, String... qualifiedName)
This constructs a field reference given the field's qualified name. jOOQ
will render the field name according to your
Settings.getRenderNameStyle()
settings. Choose
RenderNameStyle.QUOTED
to prevent syntax errors and/or SQL
injection.
Example:
// This field...
fieldByName("MY_SCHEMA", "MY_TABLE", "MY_FIELD");
// ... will render this SQL on SQL Server with RenderNameStyle.QUOTED set
[MY_SCHEMA].[MY_TABLE].[MY_FIELD]
Another example:
create.select(field("length({1})", Integer.class, fieldByName("TITLE")))
.from(tableByName("T_BOOK"))
.fetch();
// ... will execute this SQL on SQL Server:
select length([TITLE]) from [T_BOOK]
qualifiedName
- The various parts making up your field's reference
name.type
- The type of the returned fieldfieldName
@Support 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!
name
- The function name (without parentheses)type
- The function return typearguments
- The function arguments@Support 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!
name
- The function name (without parentheses)type
- The function return typearguments
- The function arguments@Support public static Condition condition(String 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!
sql
- The SQL@Support public static Condition condition(String sql, Object... bindings)
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!
sql
- The SQLbindings
- The bindings@Support public static Condition condition(String sql, QueryPart... parts)
This is useful for constructing more complex SQL syntax elements wherever
Condition
types are expected. An example for this are
Postgres's various operators, some of which are missing in the jOOQ API.
For instance, the "overlap" operator for arrays:
ARRAY[1,4,3] && ARRAY[2,1]
The above Postgres operator can be expressed as such:
condition("{0} && {1}", array1, array2);
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! One way to escape
literals is to use name(String...)
and similar methods
sql
- The SQLparts
- The QueryPart
objects that are rendered at the
{numbered placeholder} locationspublic final Query query(String 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!
query
in interface FactoryOperations
sql
- The SQLpublic final Query query(String sql, Object... bindings)
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!
query
in interface FactoryOperations
sql
- The SQLbindings
- The bindingspublic final Query query(String sql, QueryPart... parts)
Unlike FactoryOperations.query(String, Object...)
, the SQL passed to this method
should not contain any bind variables. Instead, you can pass
QueryPart
objects to the method which will be rendered at indexed
locations of your SQL string as such:
// The following query
query("select {0}, {1} from {2}", val(1), inline("test"), name("DUAL"));
// Will render this SQL on an Oracle database with RenderNameStyle.QUOTED:
select ?, 'test' from "DUAL"
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! One way to escape
literals is to use name(String...)
and similar methods
query
in interface FactoryOperations
sql
- The SQL clause, containing {numbered placeholders} where query
parts can be injectedparts
- The QueryPart
objects that are rendered at the
{numbered placeholder} locationspublic final Result<Record> fetch(String sql) throws DataAccessException
Example (Postgres):
Example
(SQLite):
String sql = "FETCH ALL IN \"
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!
fetch
in interface FactoryOperations
sql
- The SQLnull
, even if the database returns no
ResultSet
DataAccessException
- if something went wrong executing the querypublic final Result<Record> fetch(String sql, Object... bindings) throws DataAccessException
Example (Postgres):
Example
(SQLite):
String sql = "FETCH ALL IN \"
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!
fetch
in interface FactoryOperations
sql
- The SQLbindings
- The bindingsnull
, even if the database returns no
ResultSet
DataAccessException
- if something went wrong executing the querypublic final Result<Record> fetch(String sql, QueryPart... parts) throws DataAccessException
Unlike FactoryOperations.fetch(String, Object...)
, the SQL passed to this method
should not contain any bind variables. Instead, you can pass
QueryPart
objects to the method which will be rendered at indexed
locations of your SQL string as such:
// The following query
fetch("select {0}, {1} from {2}", val(1), inline("test"), name("DUAL"));
// Will execute this SQL on an Oracle database with RenderNameStyle.QUOTED:
select ?, 'test' from "DUAL"
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! One way to escape
literals is to use name(String...)
and similar methods
fetch
in interface FactoryOperations
sql
- The SQL clause, containing {numbered placeholders} where query
parts can be injectedparts
- The QueryPart
objects that are rendered at the
{numbered placeholder} locationsDataAccessException
- if something went wrong executing the querypublic final Cursor<Record> fetchLazy(String sql) throws DataAccessException
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):
Example
(SQLite):
String sql = "FETCH ALL IN \"
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!
fetchLazy
in interface FactoryOperations
sql
- The SQLnull
, even if the database returns no
ResultSet
DataAccessException
- if something went wrong executing the querypublic final Cursor<Record> fetchLazy(String sql, Object... bindings) throws DataAccessException
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):
Example
(SQLite):
String sql = "FETCH ALL IN \"
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!
fetchLazy
in interface FactoryOperations
sql
- The SQLbindings
- The bindingsnull
, even if the database returns no
ResultSet
DataAccessException
- if something went wrong executing the querypublic final Cursor<Record> fetchLazy(String sql, QueryPart... parts) throws DataAccessException
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.
Unlike FactoryOperations.fetchLazy(String, Object...)
, the SQL passed to this
method should not contain any bind variables. Instead, you can pass
QueryPart
objects to the method which will be rendered at indexed
locations of your SQL string as such:
// The following query
fetchLazy("select {0}, {1} from {2}", val(1), inline("test"), name("DUAL"));
// Will execute this SQL on an Oracle database with RenderNameStyle.QUOTED:
select ?, 'test' from "DUAL"
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! One way to escape
literals is to use name(String...)
and similar methods
fetchLazy
in interface FactoryOperations
sql
- The SQL clause, containing {numbered placeholders} where query
parts can be injectedparts
- The QueryPart
objects that are rendered at the
{numbered placeholder} locationsDataAccessException
- if something went wrong executing the querypublic final List<Result<Record>> fetchMany(String sql) throws DataAccessException
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!
fetchMany
in interface FactoryOperations
sql
- The SQLnull
, even if the database returns no
ResultSet
DataAccessException
- if something went wrong executing the querypublic final List<Result<Record>> fetchMany(String sql, Object... bindings) throws DataAccessException
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!
fetchMany
in interface FactoryOperations
sql
- The SQLbindings
- The bindingsnull
, even if the database returns no
ResultSet
DataAccessException
- if something went wrong executing the querypublic final List<Result<Record>> fetchMany(String sql, QueryPart... parts) throws DataAccessException
Unlike FactoryOperations.fetchMany(String, Object...)
, the SQL passed to this
method should not contain any bind variables. Instead, you can pass
QueryPart
objects to the method which will be rendered at indexed
locations of your SQL string as such:
// The following query
fetchMany("select {0}, {1} from {2}", val(1), inline("test"), name("DUAL"));
// Will execute this SQL on an Oracle database with RenderNameStyle.QUOTED:
select ?, 'test' from "DUAL"
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! One way to escape
literals is to use name(String...)
and similar methods
fetchMany
in interface FactoryOperations
sql
- The SQL clause, containing {numbered placeholders} where query
parts can be injectedparts
- The QueryPart
objects that are rendered at the
{numbered placeholder} locationsDataAccessException
- if something went wrong executing the querypublic final Record fetchOne(String sql) throws DataAccessException
Example (Postgres):
Example
(SQLite):
String sql = "FETCH ALL IN \"
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!
fetchOne
in interface FactoryOperations
sql
- The SQLnull
, even if the database returns no
ResultSet
DataAccessException
- if something went wrong executing the queryInvalidResultException
- if the query returned more than one recordpublic final Record fetchOne(String sql, Object... bindings) throws DataAccessException
Example (Postgres):
Example
(SQLite):
String sql = "FETCH ALL IN \"
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!
fetchOne
in interface FactoryOperations
sql
- The SQLbindings
- The bindingsnull
if the database returned no recordsDataAccessException
- if something went wrong executing the queryInvalidResultException
- if the query returned more than one recordpublic final Record fetchOne(String sql, QueryPart... parts) throws DataAccessException
Unlike FactoryOperations.fetchOne(String, Object...)
, the SQL passed to this
method should not contain any bind variables. Instead, you can pass
QueryPart
objects to the method which will be rendered at indexed
locations of your SQL string as such:
// The following query
fetchOne("select {0}, {1} from {2}", val(1), inline("test"), name("DUAL"));
// Will execute this SQL on an Oracle database with RenderNameStyle.QUOTED:
select ?, 'test' from "DUAL"
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! One way to escape
literals is to use name(String...)
and similar methods
fetchOne
in interface FactoryOperations
sql
- The SQL clause, containing {numbered placeholders} where query
parts can be injectedparts
- The QueryPart
objects that are rendered at the
{numbered placeholder} locationsnull
if the database returned no recordsDataAccessException
- if something went wrong executing the queryInvalidResultException
- if the query returned more than one recordpublic final int execute(String sql) throws DataAccessException
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!
execute
in interface FactoryOperations
sql
- The SQLDataAccessException
- if something went wrong executing the querypublic final int execute(String sql, Object... bindings) throws DataAccessException
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!
execute
in interface FactoryOperations
sql
- The SQLbindings
- The bindingsDataAccessException
- if something went wrong executing the querypublic final int execute(String sql, QueryPart... parts) throws DataAccessException
Unlike FactoryOperations.execute(String, Object...)
, the SQL passed to this method
should not contain any bind variables. Instead, you can pass
QueryPart
objects to the method which will be rendered at indexed
locations of your SQL string as such:
// The following query
execute("select {0}, {1} from {2}", val(1), inline("test"), name("DUAL"));
// Will execute this SQL on an Oracle database with RenderNameStyle.QUOTED:
select ?, 'test' from "DUAL"
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! One way to escape
literals is to use name(String...)
and similar methods
execute
in interface FactoryOperations
sql
- The SQL clause, containing {numbered placeholders} where query
parts can be injectedparts
- The QueryPart
objects that are rendered at the
{numbered placeholder} locationsDataAccessException
- if something went wrong executing the querypublic final ResultQuery<Record> resultQuery(String 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):
Example
(SQLite):
String sql = "FETCH ALL IN \"
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!
resultQuery
in interface FactoryOperations
sql
- The SQLpublic final ResultQuery<Record> resultQuery(String sql, Object... bindings)
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):
Example
(SQLite):
String sql = "FETCH ALL IN \"
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!
resultQuery
in interface FactoryOperations
sql
- The SQLbindings
- The bindingspublic final ResultQuery<Record> resultQuery(String sql, QueryPart... parts)
Unlike FactoryOperations.resultQuery(String, Object...)
, the SQL passed to this
method should not contain any bind variables. Instead, you can pass
QueryPart
objects to the method which will be rendered at indexed
locations of your SQL string as such:
// The following query
resultQuery("select {0}, {1} from {2}", val(1), inline("test"), name("DUAL"));
// Will render this SQL on an Oracle database with RenderNameStyle.QUOTED:
select ?, 'test' from "DUAL"
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! One way to escape
literals is to use name(String...)
and similar methods
resultQuery
in interface FactoryOperations
sql
- The SQL clause, containing {numbered placeholders} where query
parts can be injectedparts
- The QueryPart
objects that are rendered at the
{numbered placeholder} locationspublic final Result<Record> fetch(ResultSet rs)
ResultSet
and transform it to a jOOQ
Result
. After fetching all data, the JDBC ResultSet will be
closed.
Use FactoryOperations.fetchLazy(ResultSet)
, to fetch one Record
at a
time, instead of load the entire ResultSet
into a jOOQ
Result
at once.
fetch
in interface FactoryOperations
rs
- The JDBC ResultSet to fetch data frompublic final Cursor<Record> fetchLazy(ResultSet rs)
ResultSet
and transform it to a jOOQ
Result
. After fetching all data, the JDBC ResultSet will be
closed.
Use FactoryOperations.fetch(ResultSet)
, to load the entire ResultSet
into a jOOQ Result
at once.
fetchLazy
in interface FactoryOperations
rs
- The JDBC ResultSet to fetch data frompublic final Result<Record> fetchFromCSV(String string)
This is the same as calling fetchFromCSV(string, ',')
and
the inverse of calling Result.formatCSV()
. The first row of the
CSV data is required to hold field name information. Subsequent rows may
contain data, which is interpreted as String
. Use the various
conversion methods to retrieve other data types from the
Result
:
Result.getValues(Field, Class)
Result.getValues(int, Class)
Result.getValues(String, Class)
Result.getValues(Field, Converter)
Result.getValues(int, Converter)
Result.getValues(String, Converter)
Missing values result in null
. Empty values result in empty
Strings
fetchFromCSV
in interface FactoryOperations
string
- The CSV stringFactoryOperations.fetchFromCSV(String, char)
public final Result<Record> fetchFromCSV(String string, char delimiter)
This is inverse of calling Result.formatCSV(char)
. The first row
of the CSV data is required to hold field name information. Subsequent
rows may contain data, which is interpreted as String
. Use the
various conversion methods to retrieve other data types from the
Result
:
Result.getValues(Field, Class)
Result.getValues(int, Class)
Result.getValues(String, Class)
Result.getValues(Field, Converter)
Result.getValues(int, Converter)
Result.getValues(String, Converter)
Missing values result in null
. Empty values result in empty
Strings
fetchFromCSV
in interface FactoryOperations
string
- The CSV stringdelimiter
- The delimiter to expect between recordsFactoryOperations.fetchFromCSV(String)
@Support public static Condition trueCondition()
Condition
that will always evaluate to true@Support public static Condition falseCondition()
Condition
that will always evaluate to false@Support public static Condition exists(Select<?> query)
EXISTS ([query])
@Support public static Condition notExists(Select<?> query)
NOT EXISTS ([query])
@Support public static Condition not(Condition condition)
This is the same as calling Condition.not()
public final <R extends Record> SimpleSelectWhereStep<R> selectFrom(Table<R> table)
Example:
SELECT * FROM [table] WHERE [conditions] ORDER BY [ordering] LIMIT [limit clause]
selectFrom
in interface FactoryOperations
public final SelectSelectStep select(Field<?>... fields)
Example:
Factory create = new Factory();
create.select(field1, field2)
.from(table1)
.join(table2).on(field1.equal(field2))
.where(field1.greaterThan(100))
.orderBy(field2)
.execute();
select
in interface FactoryOperations
public final SelectSelectStep selectZero()
0
literal
Example:
Factory create = new Factory();
create.selectZero()
.from(table1)
.join(table2).on(field1.equal(field2))
.where(field1.greaterThan(100))
.orderBy(field2);
selectZero
in interface FactoryOperations
zero()
public final SelectSelectStep selectOne()
1
literal
Example:
Factory create = new Factory();
create.selectOne()
.from(table1)
.join(table2).on(field1.equal(field2))
.where(field1.greaterThan(100))
.orderBy(field2);
selectOne
in interface FactoryOperations
one()
public final SelectSelectStep selectCount()
COUNT(*)
Example:
Factory create = new Factory();
create.selectCount()
.from(table1)
.join(table2).on(field1.equal(field2))
.where(field1.greaterThan(100))
.orderBy(field2);
selectCount
in interface FactoryOperations
public final SelectSelectStep selectDistinct(Field<?>... fields)
Example:
Factory create = new Factory();
create.selectDistinct(field1, field2)
.from(table1)
.join(table2).on(field1.equal(field2))
.where(field1.greaterThan(100))
.orderBy(field2);
selectDistinct
in interface FactoryOperations
public final SelectSelectStep select(Collection<? extends Field<?>> fields)
Example:
Factory create = new Factory();
create.select(fields)
.from(table1)
.join(table2).on(field1.equal(field2))
.where(field1.greaterThan(100))
.orderBy(field2);
select
in interface FactoryOperations
public final SelectSelectStep selectDistinct(Collection<? extends Field<?>> fields)
Example:
Factory create = new Factory();
create.selectDistinct(fields)
.from(table1)
.join(table2).on(field1.equal(field2))
.where(field1.greaterThan(100))
.orderBy(field2);
selectDistinct
in interface FactoryOperations
public final SelectQuery selectQuery()
SelectQuery
selectQuery
in interface FactoryOperations
public final <R extends Record> SimpleSelectQuery<R> selectQuery(TableLike<R> table)
SelectQuery
selectQuery
in interface FactoryOperations
table
- The table to select data fromSelectQuery
public final <R extends Record> InsertQuery<R> insertQuery(Table<R> into)
InsertQuery
insertQuery
in interface FactoryOperations
into
- The table to insert data intoInsertQuery
public final <R extends Record> InsertSetStep<R> insertInto(Table<R> into)
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();
insertInto
in interface FactoryOperations
public final <R extends Record> InsertValuesStep<R> insertInto(Table<R> into, Field<?>... fields)
Example:
Factory create = new Factory();
create.insertInto(table, field1, field2)
.values(value1, value2)
.values(value3, value4)
.onDuplicateKeyUpdate()
.set(field1, value1)
.set(field2, value2)
.execute();
insertInto
in interface FactoryOperations
public final <R extends Record> InsertValuesStep<R> insertInto(Table<R> into, Collection<? extends Field<?>> fields)
Example:
Factory create = new Factory();
create.insertInto(table, field1, field2)
.values(value1, value2)
.values(value3, value4)
.onDuplicateKeyUpdate()
.set(field1, value1)
.set(field2, value2)
.execute();
insertInto
in interface FactoryOperations
@Deprecated public final <R extends Record> Insert<R> insertInto(Table<R> into, Select<?> select)
Example:
Factory create = new Factory();
create.insertInto(table, create.select(1))
.execute();
insertInto
in interface FactoryOperations
public final <R extends Record> UpdateQuery<R> updateQuery(Table<R> table)
UpdateQuery
updateQuery
in interface FactoryOperations
table
- The table to update data intoUpdateQuery
public final <R extends Record> UpdateSetStep<R> update(Table<R> table)
Example:
Factory create = new Factory();
create.update(table)
.set(field1, value1)
.set(field2, value2)
.where(field1.greaterThan(100))
.execute();
Note that some databases support table expressions more complex than
simple table references. In CUBRID and MySQL, for instance, you can write
create.update(t1.join(t2).on(t1.id.eq(t2.id)))
.set(t1.value, value1)
.set(t2.value, value2)
.where(t1.id.eq(10))
.execute();
update
in interface FactoryOperations
public final <R extends Record> MergeUsingStep<R> mergeInto(Table<R> table)
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();
Note: Using this method, you can also create an H2-specific MERGE
statement without field specification. See also
FactoryOperations.mergeInto(Table, Field...)
mergeInto
in interface FactoryOperations
public final <R extends Record> MergeKeyStep<R> mergeInto(Table<R> table, Field<?>... fields)
This statement is available from DSL syntax only. It is known to be supported in some way by any of these dialects:
H2 | H2 natively supports this special syntax | www.h2database.com/html/grammar.html#merge |
DB2, HSQLDB, Oracle, SQL Server, Sybase SQL Anywhere | These databases can simulate the H2-specific MERGE statement using a standard SQL MERGE statement, without restrictions | See FactoryOperations.mergeInto(Table) for the standard MERGE statement |
mergeInto
in interface FactoryOperations
public final <R extends Record> MergeKeyStep<R> mergeInto(Table<R> table, Collection<? extends Field<?>> fields)
mergeInto
in interface FactoryOperations
FactoryOperations.mergeInto(Table, Field...)
public final <R extends Record> DeleteQuery<R> deleteQuery(Table<R> table)
DeleteQuery
deleteQuery
in interface FactoryOperations
table
- The table to delete data fromDeleteQuery
public final <R extends Record> DeleteWhereStep<R> delete(Table<R> table)
Example:
Factory create = new Factory();
create.delete(table)
.where(field1.greaterThan(100))
.execute();
delete
in interface FactoryOperations
public final Batch batch(Query... queries)
This essentially runs the following logic:
Statement s = connection.createStatement();
for (Query query : queries) {
s.addBatch(query.getSQL(true));
}
s.execute();
batch
in interface FactoryOperations
Statement.executeBatch()
public final Batch batch(Collection<? extends Query> queries)
This essentially runs the following logic:
Statement s = connection.createStatement();
for (Query query : queries) {
s.addBatch(query.getSQL(true));
}
s.execute();
batch
in interface FactoryOperations
Statement.executeBatch()
public final BatchBindStep batch(Query query)
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();
Note: bind values will be inlined to a static batch query as in
FactoryOperations.batch(Query...)
, if you choose to execute queries with
Settings.getStatementType()
== StatementType.STATIC_STATEMENT
batch
in interface FactoryOperations
Statement.executeBatch()
public final Batch batchStore(UpdatableRecord<?>... records)
INSERT
and UPDATE
queries in
batch mode (with bind values).
This batch operation can be executed in two modes:
Settings.getStatementType()
== StatementType.PREPARED_STATEMENT
(the default)[number of distinct rendered SQL statements]
. In the worst
case, this corresponds to the number of total records.
The record type order is preserved in the way they are passed to this
method. This is an example of how statements will be ordered:
The above results in
// Let's assume, odd numbers result in INSERTs and even numbers in UPDATES
// Let's also assume a[n] are all of the same type, just as b[n], c[n]...
int[] result = create.batchStore(a1, a2, a3, b1, a4, c1, b3, a5)
.execute();
result.length == 8
and
the following 4 separate batch statements:
Settings.getStatementType()
== StatementType.STATIC_STATEMENT
batchStore
in interface FactoryOperations
Statement.executeBatch()
public final Batch batchStore(Collection<? extends UpdatableRecord<?>> records)
INSERT
and UPDATE
queries in
batch mode (with bind values).batchStore
in interface FactoryOperations
FactoryOperations.batchStore(UpdatableRecord...)
,
Statement.executeBatch()
public final <R extends Record> Truncate<R> truncate(Table<R> table)
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.
truncate
in interface FactoryOperations
public final BigInteger lastID()
Note, there are some restrictions to the following dialects:
SQLDialect.DB2
doesn't support thisSQLDialect.ORACLE
doesn't support thisSQLDialect.POSTGRES
doesn't support thisSQLDialect.SQLITE
supports this, but its support is poorly
documented.lastID
in interface FactoryOperations
null
in some
dialects, if no such number is available.public final <T extends Number> T nextval(Sequence<T> sequence)
Factory
's underlying JDBC Connection
nextval
in interface FactoryOperations
public final <T extends Number> T currval(Sequence<T> sequence)
Factory
's underlying JDBC Connection
currval
in interface FactoryOperations
public final int use(Schema schema)
This has two effects.
USE [schema]
statement is executed on those RDBMS
that support thisSchema
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] |
use
in interface FactoryOperations
public final int use(String schema)
use
in interface FactoryOperations
FactoryOperations.use(Schema)
public final <R extends UDTRecord<R>> R newRecord(UDT<R> type)
UDTRecord
.
The resulting record is attached to this Configuration
by
default. Use Settings.isAttachRecords()
to override this
behaviour.
newRecord
in interface FactoryOperations
R
- The generic record typetype
- The UDT describing records of type <R>public final <R extends TableRecord<R>> R newRecord(Table<R> table)
Record
that can be inserted into the corresponding
table.
The resulting record is attached to this Configuration
by
default. Use Settings.isAttachRecords()
to override this
behaviour.
newRecord
in interface FactoryOperations
R
- The generic record typetable
- The table holding records of type <R>public final <R extends TableRecord<R>> R newRecord(Table<R> table, Object source)
Record
that can be inserted into the
corresponding table.
This performs roughly the inverse operation of Record.into(Class)
The resulting record will have its internal "changed" flags set to true
for all values. This means that UpdatableRecord.store()
will
perform an INSERT
statement. If you wish to store the record
using an UPDATE
statement, use
FactoryOperations.executeUpdate(UpdatableRecord)
instead.
The resulting record is attached to this Configuration
by
default. Use Settings.isAttachRecords()
to override this
behaviour.
newRecord
in interface FactoryOperations
R
- The generic record typetable
- The table holding records of type <R>source
- The source to be used to fill the new recordRecord.from(Object)
,
Record.into(Class)
@Support public static Case decode()
Case
statement. Decode is used as a method name to
avoid name clashes with Java's reserved literal "case"Case
@Support public static <Z,T> Field<Z> decode(T value, T search, Z result)
DECODE(expression, search, result[, search , result]... [, default])
functiondecode(Field, Field, Field, Field[])
@Support public static <Z,T> Field<Z> decode(T value, T search, Z result, Object... more)
DECODE(expression, search, result[, search , result]... [, default])
functiondecode(Field, Field, Field, Field[])
@Support public static <Z,T> Field<Z> decode(Field<T> value, Field<T> search, Field<Z> result)
DECODE(expression, search, result[, search , result]... [, default])
functiondecode(Field, Field, Field, Field[])
@Support public static <Z,T> Field<Z> decode(Field<T> value, Field<T> search, Field<Z> result, Field<?>... more)
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
value
- The value to decodesearch
- the mandatory first search parameterresult
- the mandatory first result candidate parametermore
- 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. *@Support public static <T> Field<T> cast(Object value, Field<T> as)
T
- The generic type of the cast fieldvalue
- The value to castas
- The field whose type is used for the cast@Support public static <T> Field<T> castNull(Field<T> as)
T
- The generic type of the cast fieldas
- The field whose type is used for the cast@Support public static <T> Field<T> cast(Object value, Class<? extends T> type)
T
- The generic type of the cast fieldvalue
- The value to casttype
- The type that is used for the cast@Support public static <T> Field<T> castNull(DataType<T> type)
T
- The generic type of the cast fieldtype
- The type that is used for the cast@Support public static <T> Field<T> cast(Object value, DataType<T> type)
T
- The generic type of the cast fieldvalue
- The value to casttype
- The type that is used for the cast@Support public static <T> Field<T> castNull(Class<? extends T> type)
T
- The generic type of the cast fieldtype
- The type that is used for the cast@Support public static <T> Field<T> coalesce(T value, T... values)
COALESCE(value1, value2, ... , value n)
functioncoalesce(Field, Field...)
@Support public static <T> Field<T> coalesce(Field<T> field, Field<?>... fields)
COALESCE(field1, field2, ... , field n)
function
Returns the dialect's equivalent to COALESCE:
@Support public static <T> Field<T> nvl(T value, T defaultValue)
nvl(Field, Field)
@Support public static <T> Field<T> nvl(T value, Field<T> defaultValue)
nvl(Field, Field)
@Support public static <T> Field<T> nvl(Field<T> value, T defaultValue)
nvl(Field, Field)
@Support public static <Z> Field<Z> nvl2(Field<?> value, Z valueIfNotNull, Z valueIfNull)
nvl2(Field, Field, Field)
@Support public static <Z> Field<Z> nvl2(Field<?> value, Z valueIfNotNull, Field<Z> valueIfNull)
nvl2(Field, Field, Field)
@Support public static <Z> Field<Z> nvl2(Field<?> value, Field<Z> valueIfNotNull, Z valueIfNull)
nvl2(Field, Field, Field)
@Support public static <Z> Field<Z> nvl2(Field<?> value, Field<Z> valueIfNotNull, Field<Z> valueIfNull)
Returns the dialect's equivalent to NVL2:
Other dialects:
CASE WHEN [value] IS NULL THEN [valueIfNull] ELSE [valueIfNotNull] END
@Support public static <T> Field<T> nullif(T value, T other)
nullif(Field, Field)
@Support public static <T> Field<T> nullif(T value, Field<T> other)
nullif(Field, Field)
@Support public static <T> Field<T> nullif(Field<T> value, T other)
nullif(Field, Field)
@Support public static <T> Field<T> nullif(Field<T> value, Field<T> other)
Returns the dialect's equivalent to NULLIF:
@Support public static Field<String> upper(String value)
upper(Field)
@Support public static Field<String> upper(Field<String> field)
This renders the upper function in all dialects:
upper([field])
@Support public static Field<String> lower(String value)
lower(Field)
@Support public static Field<String> lower(Field<String> value)
This renders the lower function in all dialects:
lower([field])
@Support public static Field<String> trim(String value)
trim(Field)
@Support public static Field<String> trim(Field<String> field)
This renders the trim function where available:
... or simulates it elsewhere using
rtrim and ltrim: trim([field])
ltrim(rtrim([field]))
@Support public static Field<String> rtrim(String value)
rtrim(Field)
@Support public static Field<String> rtrim(Field<String> field)
This renders the rtrim function in all dialects:
rtrim([field])
@Support public static Field<String> ltrim(String value)
ltrim(Field)
@Support public static Field<String> ltrim(Field<String> field)
This renders the ltrim function in all dialects:
ltrim([field])
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLITE,SQLSERVER,SYBASE}) public static Field<String> rpad(Field<String> field, int length)
rpad(Field, Field)
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLITE,SQLSERVER,SYBASE}) public static Field<String> rpad(Field<String> field, Field<? extends Number> length)
This renders the rpad function where available:
... or simulates it
elsewhere using concat, repeat, and length, which may be simulated as
well, depending on the RDBMS:
rpad([field], [length])
concat([field], repeat(' ', [length] - length([field])))
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLITE,SQLSERVER,SYBASE}) public static Field<String> rpad(Field<String> field, int length, char character)
rpad(Field, Field, Field)
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLITE,SQLSERVER,SYBASE}) public static Field<String> rpad(Field<String> field, int length, String character)
rpad(Field, Field, Field)
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLITE,SQLSERVER,SYBASE}) public static Field<String> rpad(Field<String> field, Field<? extends Number> length, Field<String> character)
This renders the rpad function where available:
... or simulates it
elsewhere using concat, repeat, and length, which may be simulated as
well, depending on the RDBMS:
rpad([field], [length])
concat([field], repeat([character], [length] - length([field])))
In SQLDialect.SQLITE
, this is simulated as such:
[field] || replace(replace(substr(quote(zeroblob(([length] + 1) / 2)), 3, ([length] - length([field]))), '''', ''), '0', [character])
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLITE,SQLSERVER,SYBASE}) public static Field<String> lpad(Field<String> field, int length)
lpad(Field, Field)
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLITE,SQLSERVER,SYBASE}) public static Field<String> lpad(Field<String> field, Field<? extends Number> length)
This renders the lpad function where available:
... or simulates it
elsewhere using concat, repeat, and length, which may be simulated as
well, depending on the RDBMS:
lpad([field], [length])
concat(repeat(' ', [length] - length([field])), [field])
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLITE,SQLSERVER,SYBASE}) public static Field<String> lpad(Field<String> field, int length, char character)
lpad(Field, Field, Field)
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLITE,SQLSERVER,SYBASE}) public static Field<String> lpad(Field<String> field, int length, String character)
lpad(Field, Field, Field)
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLITE,SQLSERVER,SYBASE}) public static Field<String> lpad(Field<String> field, Field<? extends Number> length, Field<String> character)
This renders the lpad function where available:
... or simulates it
elsewhere using concat, repeat, and length, which may be simulated as
well, depending on the RDBMS:
lpad([field], [length])
concat(repeat([character], [length] - length([field])), [field])
In SQLDialect.SQLITE
, this is simulated as such:
replace(replace(substr(quote(zeroblob(([length] + 1) / 2)), 3, ([length] - length([field]))), '''', ''), '0', [character]) || [field]
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLITE,SQLSERVER,SYBASE}) public static Field<String> repeat(String field, int count)
repeat(Field, Field)
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLITE,SQLSERVER,SYBASE}) public static Field<String> repeat(String field, Field<? extends Number> count)
repeat(Field, Field)
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLITE,SQLSERVER,SYBASE}) public static Field<String> repeat(Field<String> field, int count)
repeat(Field, Field)
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLITE,SQLSERVER,SYBASE}) public static Field<String> repeat(Field<String> field, Field<? extends Number> count)
This renders the repeat or replicate function where available:
... or simulates it elsewhere
using rpad and length, which may be simulated as well, depending on the
RDBMS:
repeat([field], [count]) or
replicate([field], [count])
rpad([field], length([field]) * [count], [field])
In SQLDialect.SQLITE
, this is simulated as such:
replace(substr(quote(zeroblob(([count] + 1) / 2)), 3, [count]), '0', [field])
@Support public static String escape(String value, char escape)
replace(Field, String, String)
to escape
data for use with Field.like(Field, char)
Essentially, this escapes %
and _
characters
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE,SQLITE}) public static Field<String> escape(Field<String> field, char escape)
replace(Field, String, String)
to escape
data for use with Field.like(Field, char)
Essentially, this escapes %
and _
characters
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE,SQLITE}) public static Field<String> replace(Field<String> field, String search)
replace(Field, Field)
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE,SQLITE}) public static Field<String> replace(Field<String> field, Field<String> search)
This renders the replace or str_replace function where available:
... or simulates it elsewhere
using the three-argument replace function:
replace([field], [search]) or
str_replace([field], [search])
replace([field], [search], '')
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE,SQLITE}) public static Field<String> replace(Field<String> field, String search, String replace)
replace(Field, Field, Field)
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE,SQLITE}) public static Field<String> replace(Field<String> field, Field<String> search, Field<String> replace)
This renders the replace or str_replace function:
replace([field], [search]) or
str_replace([field], [search])
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static Field<Integer> position(String in, String search)
position(Field, Field)
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static Field<Integer> position(String in, Field<String> search)
position(Field, Field)
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static Field<Integer> position(Field<String> in, String search)
position(Field, Field)
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static Field<Integer> position(Field<String> in, Field<String> search)
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])
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static Field<Integer> ascii(String field)
ascii(Field)
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static Field<Integer> ascii(Field<String> field)
This renders the ascii function:
ascii([field])
@Support public static Field<String> concat(String... values)
concat(Field...)
@Support public static Field<String> concat(Field<?>... fields)
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)
@Support public static Field<String> substring(Field<String> field, int startingPosition)
substring(Field, Field)
@Support public static Field<String> substring(Field<String> field, Field<? extends Number> startingPosition)
This renders the substr or substring function:
substr([field], [startingPosition]) or
substring([field], [startingPosition])
@Support public static Field<String> substring(Field<String> field, int startingPosition, int length)
substring(Field, Field, Field)
@Support public static Field<String> substring(Field<String> field, Field<? extends Number> startingPosition, Field<? extends Number> length)
This renders the substr or substring function:
substr([field], [startingPosition], [length]) or
substring([field], [startingPosition], [length])
@Support public static Field<Integer> length(String value)
VARCHAR
type. This is a synonym for
charLength(String)
charLength(String)
@Support public static Field<Integer> length(Field<String> field)
VARCHAR
type. This is a synonym for
charLength(Field)
charLength(Field)
@Support public static Field<Integer> charLength(String value)
This translates into any dialect
@Support public static Field<Integer> charLength(Field<String> field)
This translates into any dialect
@Support public static Field<Integer> bitLength(String value)
This translates into any dialect
@Support public static Field<Integer> bitLength(Field<String> field)
This translates into any dialect
@Support public static Field<Integer> octetLength(String value)
This translates into any dialect
@Support public static Field<Integer> octetLength(Field<String> field)
This translates into any dialect
@Support public static Field<Date> currentDate()
This translates into any dialect
@Support public static Field<Time> currentTime()
This translates into any dialect
@Support public static Field<Timestamp> currentTimestamp()
This translates into any dialect
@Support public static Field<Integer> dateDiff(Date date1, Date date2)
This translates into any dialect
Field.sub(Field)
@Support public static Field<Integer> dateDiff(Field<Date> date1, Date date2)
This translates into any dialect
Field.sub(Field)
@Support public static Field<Date> dateAdd(Date date, Number interval)
This translates into any dialect
Field.add(Number)
@Support public static Field<Date> dateAdd(Field<Date> date, Field<? extends Number> interval)
This translates into any dialect
Field.add(Field)
@Support public static Field<Integer> dateDiff(Date date1, Field<Date> date2)
This translates into any dialect
Field.sub(Field)
@Support public static Field<Integer> dateDiff(Field<Date> date1, Field<Date> date2)
This translates into any dialect
Field.sub(Field)
@Support public static Field<Timestamp> timestampAdd(Timestamp timestamp, Number interval)
This translates into any dialect
Field.add(Number)
@Support public static Field<Timestamp> timestampAdd(Field<Timestamp> timestamp, Field<? extends Number> interval)
This translates into any dialect
Field.add(Field)
@Support public static Field<DayToSecond> timestampDiff(Timestamp timestamp1, Timestamp timestamp2)
INTERVAL DAY TO SECOND
type
This translates into any dialect
Field.sub(Field)
@Support public static Field<DayToSecond> timestampDiff(Field<Timestamp> timestamp1, Timestamp timestamp2)
INTERVAL DAY TO SECOND
type
This translates into any dialect
Field.sub(Field)
@Support public static Field<DayToSecond> timestampDiff(Timestamp timestamp1, Field<Timestamp> timestamp2)
INTERVAL DAY TO SECOND
type
This translates into any dialect
Field.sub(Field)
@Support public static Field<DayToSecond> timestampDiff(Field<Timestamp> timestamp1, Field<Timestamp> timestamp2)
INTERVAL DAY TO SECOND
type
This translates into any dialect
Field.sub(Field)
@Support public static Field<Integer> extract(Date value, DatePart datePart)
This translates into any dialect
@Support public static Field<Integer> extract(Field<? extends Date> field, DatePart datePart)
This translates into any dialect
@Support public static Field<Integer> year(Date value)
This is the same as calling extract(java.util.Date, DatePart)
with DatePart.YEAR
@Support public static Field<Integer> year(Field<? extends Date> field)
This is the same as calling extract(Field, DatePart)
with DatePart.YEAR
@Support public static Field<Integer> month(Date value)
This is the same as calling extract(java.util.Date, DatePart)
with DatePart.MONTH
@Support public static Field<Integer> month(Field<? extends Date> field)
This is the same as calling extract(Field, DatePart)
with DatePart.MONTH
@Support public static Field<Integer> day(Date value)
This is the same as calling extract(java.util.Date, DatePart)
with DatePart.DAY
@Support public static Field<Integer> day(Field<? extends Date> field)
This is the same as calling extract(Field, DatePart)
with DatePart.DAY
@Support public static Field<Integer> hour(Date value)
This is the same as calling extract(java.util.Date, DatePart)
with DatePart.HOUR
@Support public static Field<Integer> hour(Field<? extends Date> field)
This is the same as calling extract(Field, DatePart)
with DatePart.HOUR
@Support public static Field<Integer> minute(Date value)
This is the same as calling extract(java.util.Date, DatePart)
with DatePart.MINUTE
@Support public static Field<Integer> minute(Field<? extends Date> field)
This is the same as calling extract(Field, DatePart)
with DatePart.MINUTE
@Support public static Field<Integer> second(Date value)
This is the same as calling extract(java.util.Date, DatePart)
with DatePart.SECOND
@Support public static Field<Integer> second(Field<? extends Date> field)
This is the same as calling extract(Field, DatePart)
with DatePart.SECOND
@Support(value={CUBRID,DB2,MYSQL,ORACLE,SQLSERVER,SYBASE}) public static Field<?> rollup(Field<?>... fields)
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
fields
- The fields that are part of the ROLLUP
functionGROUP BY
clause@Support(value={DB2,ORACLE,SQLSERVER,SYBASE}) public static Field<?> cube(Field<?>... fields)
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
fields
- The fields that are part of the CUBE
functionGROUP BY
clause@Support(value={DB2,ORACLE,SQLSERVER,SYBASE}) public static Field<?> groupingSets(Field<?>... fields)
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
fields
- The fields that are part of the GROUPING SETS
functionGROUP BY
clause@Support(value={DB2,ORACLE,SQLSERVER,SYBASE}) public static Field<?> groupingSets(Field<?>[]... fieldSets)
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
fieldSets
- The fields that are part of the GROUPING SETS
functionGROUP BY
clause@Support(value={DB2,ORACLE,SQLSERVER,SYBASE}) public static Field<?> groupingSets(Collection<Field<?>>... fieldSets)
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
fieldSets
- The fields that are part of the GROUPING SETS
functionGROUP BY
clause@Support(value={DB2,ORACLE,SQLSERVER,SYBASE}) public static Field<Integer> grouping(Field<?> field)
CUBE
, ROLLUP
, and GROUPING SETS
groupings
This has been observed to work with the following databases:
field
- The function argumentGROUPING
aggregation fieldcube(Field...)
,
rollup(Field...)
@Support(value={ORACLE,SQLSERVER}) public static Field<Integer> groupingId(Field<?>... fields)
CUBE
, ROLLUP
, and
GROUPING SETS
groupings
This has been observed to work with the following databases:
fields
- The function argumentsGROUPING_ID
aggregation fieldcube(Field...)
,
rollup(Field...)
@Support(value={CUBRID,FIREBIRD,FIREBIRD,H2,HSQLDB,MYSQL,ORACLE,POSTGRES,SYBASE,SQLITE}) public static Field<Integer> bitCount(Number value)
BIT_COUNT(field)
function, counting the number of
bits that are set in this number.bitCount(Field)
@Support(value={CUBRID,FIREBIRD,FIREBIRD,H2,HSQLDB,MYSQL,ORACLE,POSTGRES,SYBASE,SQLITE}) public static Field<Integer> bitCount(Field<? extends Number> field)
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
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE,SQLITE}) public static <T extends Number> Field<T> bitNot(T value)
bitNot(Field)
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE,SQLITE}) public static <T extends Number> Field<T> bitNot(Field<T> field)
Most dialects natively support this using ~[field]
. jOOQ
simulates this operator in some dialects using -[field] - 1
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE,SQLITE}) public static <T extends Number> Field<T> bitAnd(T value1, T value2)
bitAnd(Field, Field)
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE,SQLITE}) public static <T extends Number> Field<T> bitAnd(T value1, Field<T> value2)
bitAnd(Field, Field)
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE,SQLITE}) public static <T extends Number> Field<T> bitAnd(Field<T> value1, T value2)
bitAnd(Field, Field)
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE,SQLITE}) public static <T extends Number> Field<T> bitAnd(Field<T> field1, Field<T> field2)
This is not supported by Derby, Ingres
This renders the and operation where available:
... or the and function elsewhere:
[field1] & [field2]
bitand([field1], [field2])
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE,SQLITE}) public static <T extends Number> Field<T> bitNand(T value1, T value2)
bitNand(Field, Field)
,
bitNot(Field)
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE,SQLITE}) public static <T extends Number> Field<T> bitNand(T value1, Field<T> value2)
bitNand(Field, Field)
,
bitNot(Field)
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE,SQLITE}) public static <T extends Number> Field<T> bitNand(Field<T> value1, T value2)
bitNand(Field, Field)
,
bitNot(Field)
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE,SQLITE}) public static <T extends Number> Field<T> bitNand(Field<T> field1, Field<T> field2)
This is not supported by Derby, Ingres
This renders the not and operation where available:
... or the not and function elsewhere:
~([field1] & [field2])
bitnot(bitand([field1], [field2]))
bitNot(Field)
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE,SQLITE}) public static <T extends Number> Field<T> bitOr(T value1, T value2)
bitOr(Field, Field)
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE,SQLITE}) public static <T extends Number> Field<T> bitOr(T value1, Field<T> value2)
bitOr(Field, Field)
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE,SQLITE}) public static <T extends Number> Field<T> bitOr(Field<T> value1, T value2)
bitOr(Field, Field)
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE,SQLITE}) public static <T extends Number> Field<T> bitOr(Field<T> field1, Field<T> field2)
This is not supported by Derby, Ingres
This renders the or operation where available:
... or the or function elsewhere:
[field1] | [field2]
bitor([field1], [field2])
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE,SQLITE}) public static <T extends Number> Field<T> bitNor(T value1, T value2)
bitNor(Field, Field)
,
bitNot(Field)
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE,SQLITE}) public static <T extends Number> Field<T> bitNor(T value1, Field<T> value2)
bitNor(Field, Field)
,
bitNot(Field)
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE,SQLITE}) public static <T extends Number> Field<T> bitNor(Field<T> value1, T value2)
bitNor(Field, Field)
,
bitNot(Field)
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE,SQLITE}) public static <T extends Number> Field<T> bitNor(Field<T> field1, Field<T> field2)
This is not supported by Derby, Ingres
This renders the not or operation where available:
... or the not or function elsewhere:
~([field1] | [field2])
bitnot(bitor([field1], [field2]))
bitNot(Field)
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE,SQLITE}) public static <T extends Number> Field<T> bitXor(T value1, T value2)
bitXor(Field, Field)
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE,SQLITE}) public static <T extends Number> Field<T> bitXor(T value1, Field<T> value2)
bitXor(Field, Field)
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE,SQLITE}) public static <T extends Number> Field<T> bitXor(Field<T> value1, T value2)
bitXor(Field, Field)
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE,SQLITE}) public static <T extends Number> Field<T> bitXor(Field<T> field1, Field<T> field2)
This is not supported by Derby, Ingres
This renders the or operation where available:
... or the xor function elsewhere:
[field1] ^ [field2]
bitxor([field1], [field2])
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE,SQLITE}) public static <T extends Number> Field<T> bitXNor(T value1, T value2)
bitXNor(Field, Field)
,
bitNot(Field)
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE,SQLITE}) public static <T extends Number> Field<T> bitXNor(T value1, Field<T> value2)
bitXNor(Field, Field)
,
bitNot(Field)
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE,SQLITE}) public static <T extends Number> Field<T> bitXNor(Field<T> value1, T value2)
bitXNor(Field, Field)
,
bitNot(Field)
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE,SQLITE}) public static <T extends Number> Field<T> bitXNor(Field<T> field1, Field<T> field2)
This is not supported by Derby, Ingres
This renders the or operation where available:
... or the not xor function elsewhere:
~([field1] ^ [field2])
bitnot(bitxor([field1], [field2]))
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE,SQLITE}) public static <T extends Number> Field<T> shl(T value1, T value2)
shl(Field, Field)
,
power(Field, Number)
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE,SQLITE}) public static <T extends Number> Field<T> shl(T value1, Field<T> value2)
shl(Field, Field)
,
power(Field, Number)
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE,SQLITE}) public static <T extends Number> Field<T> shl(Field<T> value1, T value2)
shl(Field, Field)
,
power(Field, Number)
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE,SQLITE}) public static <T extends Number> Field<T> shl(Field<T> field1, Field<T> field2)
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.
power(Field, Field)
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE,SQLITE}) public static <T extends Number> Field<T> shr(T value1, T value2)
shr(Field, Field)
,
power(Field, Number)
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE,SQLITE}) public static <T extends Number> Field<T> shr(T value1, Field<T> value2)
shr(Field, Field)
,
power(Field, Number)
@Support(value={ASE,CUBRID,DB2,FIREBIRD,H2,HSQLDB,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE,SQLITE}) public static <T extends Number> Field<T> shr(Field<T> value1, T value2)
shr(Field, Field)
,
power(Field, Number)
@Support(value={ASE,CUBRID,DB2,H2,FIREBIRD,HSQLDB,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE,SQLITE}) public static <T extends Number> Field<T> shr(Field<T> field1, Field<T> field2)
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.
power(Field, Field)
@Support public static Field<BigDecimal> rand()
@Support public static <T> Field<T> greatest(T value, T... 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.
greatest(Field, Field...)
@Support public static <T> Field<T> greatest(Field<T> field, Field<?>... others)
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.
@Support public static <T> Field<T> least(T value, T... 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(Field, Field...)
@Support public static <T> Field<T> least(Field<T> field, Field<?>... others)
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.
@Support public static Field<Integer> sign(Number value)
sign(Field)
@Support public static Field<Integer> sign(Field<? extends Number> field)
This renders the sign function where available:
... or simulates it elsewhere (without bind variables on values -1, 0, 1):
sign([field])
CASE WHEN [this] > 0 THEN 1
WHEN [this] < 0 THEN -1
ELSE 0
END
@Support public static <T extends Number> Field<T> abs(T value)
abs(Field)
@Support public static <T extends Number> Field<T> abs(Field<T> field)
This renders the same on all dialects:
abs([field])
@Support public static <T extends Number> Field<T> round(T value)
round(Field)
@Support public static <T extends Number> Field<T> round(Field<T> field)
This renders the round function where available:
... or simulates it elsewhere using floor and ceilround([field]) or
round([field], 0)
@Support public static <T extends Number> Field<T> round(T value, int decimals)
round(Field, int)
@Support public static <T extends Number> Field<T> round(Field<T> field, int decimals)
This renders the round function where available:
... or simulates it elsewhere using floor and ceilround([field], [decimals])
@Support public static <T extends Number> Field<T> floor(T value)
floor(Field)
@Support public static <T extends Number> Field<T> floor(Field<T> field)
This renders the floor function where available:
... or simulates it elsewhere using round:
floor([this])
round([this] - 0.499999999999999)
@Support public static <T extends Number> Field<T> ceil(T value)
ceil(Field)
@Support public static <T extends Number> Field<T> ceil(Field<T> field)
This renders the ceil or ceiling function where available:
... or simulates it elsewhere using round:
ceil([field]) or
ceiling([field])
round([field] + 0.499999999999999)
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static <T extends Number> Field<T> trunc(T number)
trunc(Field, Field)
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static <T extends Number> Field<T> trunc(T number, int decimals)
trunc(Field, Field)
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static <T extends Number> Field<T> trunc(Field<T> number, int decimals)
trunc(Field, Field)
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static <T extends Number> Field<T> trunc(T number, Field<Integer> decimals)
trunc(Field, Field)
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static <T extends Number> Field<T> trunc(Field<T> number, Field<Integer> decimals)
This function truncates number
to the amount of decimals
specified in decimals
. Passing decimals = 0
to
this function is the same as using floor(Field)
. Passing
positive values for decimal
has a similar effect as
round(Field, int)
. Passing negative values for
decimal
will truncate number
to a given power
of 10. Some examples
Function call | yields... |
---|---|
trunc(125.815) | 125 |
trunc(125.815, 0) | 125 |
trunc(125.815, 1) | 125.8 |
trunc(125.815, 2) | 125.81 |
trunc(125.815, -1) | 120 |
trunc(125.815, -2) | 100 |
trunc(Field, Field)
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static Field<BigDecimal> sqrt(Number value)
sqrt(Field)
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static Field<BigDecimal> sqrt(Field<? extends Number> field)
This renders the sqrt function where available:
... or simulates it elsewhere using
power (which in turn may also be simulated using ln and exp functions):
sqrt([field])
power([field], 0.5)
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static Field<BigDecimal> exp(Number value)
exp(Field)
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static Field<BigDecimal> exp(Field<? extends Number> field)
This renders the same on all dialects:
exp([field])
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static Field<BigDecimal> ln(Number value)
ln(Field)
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static Field<BigDecimal> ln(Field<? extends Number> field)
This renders the ln or log function where available:
ln([field]) or
log([field])
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static Field<BigDecimal> log(Number value, int base)
log(Field, int)
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static Field<BigDecimal> log(Field<? extends Number> field, int base)
This renders the log function where available:
... or simulates it elsewhere (in
most RDBMS) using the natural logarithm:
log([field])
ln([field]) / ln([base])
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static Field<BigDecimal> power(Number value, Number exponent)
power(Field, Field)
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static Field<BigDecimal> power(Field<? extends Number> field, Number exponent)
power(Field, Field)
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static Field<BigDecimal> power(Number value, Field<? extends Number> exponent)
power(Field, Field)
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static Field<BigDecimal> power(Field<? extends Number> field, Field<? extends Number> exponent)
This renders the power function where available:
... or simulates it
elsewhere using ln and exp:
power([field], [exponent])
exp(ln([field]) * [exponent])
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static Field<BigDecimal> acos(Number value)
acos(Field)
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static Field<BigDecimal> acos(Field<? extends Number> field)
This renders the acos function where available:
acos([field])
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static Field<BigDecimal> asin(Number value)
asin(Field)
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static Field<BigDecimal> asin(Field<? extends Number> field)
This renders the asin function where available:
asin([field])
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static Field<BigDecimal> atan(Number value)
atan(Field)
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static Field<BigDecimal> atan(Field<? extends Number> field)
This renders the atan function where available:
atan([field])
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static Field<BigDecimal> atan2(Number x, Number y)
atan2(Field, Field)
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static Field<BigDecimal> atan2(Number x, Field<? extends Number> y)
atan2(Field, Field)
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static Field<BigDecimal> atan2(Field<? extends Number> x, Number y)
atan2(Field, Field)
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static Field<BigDecimal> atan2(Field<? extends Number> x, Field<? extends Number> y)
This renders the atan2 or atn2 function where available:
atan2([x], [y]) or
atn2([x], [y])
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static Field<BigDecimal> cos(Number value)
cos(Field)
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static Field<BigDecimal> cos(Field<? extends Number> field)
This renders the cos function where available:
cos([field])
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static Field<BigDecimal> sin(Number value)
sin(Field)
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static Field<BigDecimal> sin(Field<? extends Number> field)
This renders the sin function where available:
sin([field])
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static Field<BigDecimal> tan(Number value)
tan(Field)
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static Field<BigDecimal> tan(Field<? extends Number> field)
This renders the tan function where available:
tan([field])
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static Field<BigDecimal> cot(Number value)
cot(Field)
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static Field<BigDecimal> cot(Field<? extends Number> field)
This renders the cot function where available:
... or simulates it elsewhere using
sin and cos: cot([field])
cos([field]) / sin([field])
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static Field<BigDecimal> sinh(Number value)
sinh(Field)
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static Field<BigDecimal> sinh(Field<? extends Number> field)
This renders the sinh function where available:
... or simulates it elsewhere using
exp: sinh([field])
(exp([field] * 2) - 1) / (exp([field] * 2))
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static Field<BigDecimal> cosh(Number value)
cosh(Field)
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static Field<BigDecimal> cosh(Field<? extends Number> field)
This renders the cosh function where available:
... or simulates it elsewhere using
exp: cosh([field])
(exp([field] * 2) + 1) / (exp([field] * 2))
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static Field<BigDecimal> tanh(Number value)
tanh(Field)
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static Field<BigDecimal> tanh(Field<? extends Number> field)
This renders the tanh function where available:
... or simulates it elsewhere using
exp:
tanh([field])
(exp([field] * 2) - 1) / (exp([field] * 2) + 1)
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static Field<BigDecimal> coth(Number value)
coth(Field)
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static Field<BigDecimal> coth(Field<? extends Number> field)
This is not supported by any RDBMS, but simulated using exp exp:
(exp([field] * 2) + 1) / (exp([field] * 2) - 1)
@Support public static Field<BigDecimal> deg(Number value)
deg(Field)
@Support public static Field<BigDecimal> deg(Field<? extends Number> field)
This renders the degrees function where available:
... or simulates it elsewhere:
degrees([field])
[field] * 180 / PI
@Support public static Field<BigDecimal> rad(Number value)
rad(Field)
@Support public static Field<BigDecimal> rad(Field<? extends Number> field)
This renders the degrees function where available:
... or simulates it elsewhere:
degrees([field])
[field] * PI / 180
@Support(value={CUBRID,ORACLE}) public static Field<Integer> level()
LEVEL
pseudo-field (to be used
along with CONNECT BY
clauses)@Support(value={CUBRID,ORACLE}) public static Field<Boolean> connectByIsCycle()
CONNECT_BY_ISCYCLE
pseudo-field
(to be used along with CONNECT BY
clauses)@Support(value={CUBRID,ORACLE}) public static Field<Boolean> connectByIsLeaf()
CONNECT_BY_ISLEAF
pseudo-field
(to be used along with CONNECT BY
clauses)@Support(value={CUBRID,ORACLE}) public static <T> Field<T> connectByRoot(Field<T> field)
CONNECT_BY_ROOT
pseudo-column
(to be used along with CONNECT BY
clauses)@Support(value={CUBRID,ORACLE}) public static Field<String> sysConnectByPath(Field<?> field, String separator)
SYS_CONNECT_BY_PATH(field, separator)
function (to be used
along with CONNECT BY
clauses).@Support(value={CUBRID,ORACLE}) public static <T> Field<T> prior(Field<T> field)
PRIOR
unary operator before a field
(to be used along with CONNECT BY
clauses)@Support public static AggregateFunction<Integer> count()
@Support public static AggregateFunction<Integer> count(Field<?> field)
@Support public static AggregateFunction<Integer> countDistinct(Field<?> field)
@Support(value={HSQLDB,MYSQL}) public static AggregateFunction<Integer> countDistinct(Field<?>... fields)
Some dialects support several expressions in the COUNT(DISTINCT expr1, expr2)
aggregate function.
@Support public static <T> AggregateFunction<T> max(Field<T> field)
@Support public static <T> AggregateFunction<T> maxDistinct(Field<T> field)
@Support public static <T> AggregateFunction<T> min(Field<T> field)
@Support public static <T> AggregateFunction<T> minDistinct(Field<T> field)
@Support public static AggregateFunction<BigDecimal> sum(Field<? extends Number> field)
@Support public static AggregateFunction<BigDecimal> sumDistinct(Field<? extends Number> field)
@Support public static AggregateFunction<BigDecimal> avg(Field<? extends Number> field)
@Support public static AggregateFunction<BigDecimal> avgDistinct(Field<? extends Number> field)
@Support(value={HSQLDB,ORACLE,SYBASE}) public static AggregateFunction<BigDecimal> median(Field<? extends Number> field)
@Support(value={ASE,CUBRID,DB2,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static AggregateFunction<BigDecimal> stddevPop(Field<? extends Number> field)
@Support(value={ASE,CUBRID,DB2,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static AggregateFunction<BigDecimal> stddevSamp(Field<? extends Number> field)
@Support(value={ASE,CUBRID,DB2,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static AggregateFunction<BigDecimal> varPop(Field<? extends Number> field)
@Support(value={ASE,CUBRID,DB2,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static AggregateFunction<BigDecimal> varSamp(Field<? extends Number> field)
@Support(value={DB2,POSTGRES,ORACLE,SYBASE}) public static AggregateFunction<BigDecimal> regrSlope(Field<? extends Number> y, Field<? extends Number> x)
REGR_SLOPE
linear regression function
The linear regression functions fit an ordinary-least-squares regression line to a set of number pairs. You can use them as both aggregate and window functions, where this is supported.
Note that SQLDialect.DB2
does not support linear regression
window functions.
@Support(value={DB2,POSTGRES,ORACLE,SYBASE}) public static AggregateFunction<BigDecimal> regrIntercept(Field<? extends Number> y, Field<? extends Number> x)
REGR_INTERCEPT
linear regression function
The linear regression functions fit an ordinary-least-squares regression line to a set of number pairs. You can use them as both aggregate and window functions, where this is supported.
Note that SQLDialect.DB2
does not support linear regression
window functions.
@Support(value={DB2,POSTGRES,ORACLE,SYBASE}) public static AggregateFunction<BigDecimal> regrCount(Field<? extends Number> y, Field<? extends Number> x)
REGR_COUNT
linear regression function
The linear regression functions fit an ordinary-least-squares regression line to a set of number pairs. You can use them as both aggregate and window functions, where this is supported.
Note that SQLDialect.DB2
does not support linear regression
window functions.
@Support(value={DB2,POSTGRES,ORACLE,SYBASE}) public static AggregateFunction<BigDecimal> regrR2(Field<? extends Number> y, Field<? extends Number> x)
REGR_R2
linear regression function
The linear regression functions fit an ordinary-least-squares regression line to a set of number pairs. You can use them as both aggregate and window functions, where this is supported.
Note that SQLDialect.DB2
does not support linear regression
window functions.
@Support(value={DB2,POSTGRES,ORACLE,SYBASE}) public static AggregateFunction<BigDecimal> regrAvgX(Field<? extends Number> y, Field<? extends Number> x)
REGR_AVGX
linear regression function
The linear regression functions fit an ordinary-least-squares regression line to a set of number pairs. You can use them as both aggregate and window functions, where this is supported.
Note that SQLDialect.DB2
does not support linear regression
window functions.
@Support(value={DB2,POSTGRES,ORACLE,SYBASE}) public static AggregateFunction<BigDecimal> regrAvgY(Field<? extends Number> y, Field<? extends Number> x)
REGR_AVGY
linear regression function
The linear regression functions fit an ordinary-least-squares regression line to a set of number pairs. You can use them as both aggregate and window functions, where this is supported.
Note that SQLDialect.DB2
does not support linear regression
window functions.
@Support(value={DB2,POSTGRES,ORACLE,SYBASE}) public static AggregateFunction<BigDecimal> regrSXX(Field<? extends Number> y, Field<? extends Number> x)
REGR_SXX
linear regression function
The linear regression functions fit an ordinary-least-squares regression line to a set of number pairs. You can use them as both aggregate and window functions, where this is supported.
Note that SQLDialect.DB2
does not support linear regression
window functions.
@Support(value={DB2,POSTGRES,ORACLE,SYBASE}) public static AggregateFunction<BigDecimal> regrSYY(Field<? extends Number> y, Field<? extends Number> x)
REGR_SYY
linear regression function
The linear regression functions fit an ordinary-least-squares regression line to a set of number pairs. You can use them as both aggregate and window functions, where this is supported.
Note that SQLDialect.DB2
does not support linear regression
window functions.
@Support(value={DB2,POSTGRES,ORACLE,SYBASE}) public static AggregateFunction<BigDecimal> regrSXY(Field<? extends Number> y, Field<? extends Number> x)
REGR_SXY
linear regression function
The linear regression functions fit an ordinary-least-squares regression line to a set of number pairs. You can use them as both aggregate and window functions, where this is supported.
Note that SQLDialect.DB2
does not support linear regression
window functions.
@Support(value={CUBRID,DB2,H2,HSQLDB,MYSQL,ORACLE,POSTGRES,SYBASE}) public static OrderedAggregateFunction<String> listAgg(Field<?> field)
This is natively supported by SQLDialect.ORACLE
. It is simulated
by the following dialects:
SQLDialect.CUBRID
: Using GROUP_CONCAT()
SQLDialect.DB2
: Using XMLAGG()
SQLDialect.H2
: Using GROUP_CONCAT()
SQLDialect.HSQLDB
: Using GROUP_CONCAT()
SQLDialect.MYSQL
: Using GROUP_CONCAT()
SQLDialect.POSTGRES
: Using STRING_AGG()
SQLDialect.SYBASE
: Using LIST()
groupConcat(Field)
@Support(value={CUBRID,DB2,H2,HSQLDB,MYSQL,ORACLE,POSTGRES,SYBASE}) public static OrderedAggregateFunction<String> listAgg(Field<?> field, String separator)
This is natively supported by SQLDialect.ORACLE
. It is simulated
by the following dialects:
SQLDialect.CUBRID
: Using GROUP_CONCAT
SQLDialect.DB2
: Using XMLAGG()
SQLDialect.H2
: Using GROUP_CONCAT
SQLDialect.HSQLDB
: Using GROUP_CONCAT
SQLDialect.MYSQL
: Using GROUP_CONCAT
SQLDialect.POSTGRES
: Using STRING_AGG()
SQLDialect.SYBASE
: Using LIST()
groupConcat(Field)
@Support(value={CUBRID,DB2,H2,HSQLDB,MYSQL,ORACLE,POSTGRES,SYBASE}) public static GroupConcatOrderByStep groupConcat(Field<?> field)
This is natively supported by
It is simulated by the following dialects:
SQLDialect.DB2
: Using XMLAGG()
SQLDialect.ORACLE
: Using LISTAGG()
SQLDialect.POSTGRES
: Using STRING_AGG()
SQLDialect.SYBASE
: Using LIST()
listAgg(Field)
@Support(value={CUBRID,H2,HSQLDB,MYSQL,POSTGRES,SYBASE}) public static GroupConcatOrderByStep groupConcatDistinct(Field<?> field)
This is natively supported by
It is simulated by the following dialects:
SQLDialect.SYBASE
: Using LIST()
SQLDialect.POSTGRES
: Using STRING_AGG()
listAgg(Field)
@Support(value={DB2,DERBY,H2,HSQLDB,POSTGRES,ORACLE,SQLSERVER,SYBASE}) public static WindowOverStep<Integer> rowNumber()
row_number() over ([analytic clause])
function.
Window functions are supported in DB2, Postgres, Oracle, SQL Server and Sybase.
Newer versions of SQLDialect.DERBY
and SQLDialect.H2
also
support the ROW_NUMBER() OVER()
window function without any
window clause. See the respective docs for details.
SQLDialect.HSQLDB
can simulate this function using
ROWNUM()
@Support(value={DB2,POSTGRES,ORACLE,SQLSERVER,SYBASE}) public static WindowOverStep<Integer> rank()
rank_over() over ([analytic clause])
function.
Window functions are supported in DB2, Postgres, Oracle, SQL Server and Sybase.
@Support(value={DB2,POSTGRES,ORACLE,SQLSERVER,SYBASE}) public static WindowOverStep<Integer> denseRank()
dense_rank() over ([analytic clause])
function.
Window functions are supported in DB2, Postgres, Oracle, SQL Server and Sybase.
@Support(value={POSTGRES,ORACLE,SYBASE}) public static WindowOverStep<BigDecimal> percentRank()
precent_rank() over ([analytic clause])
function.
Window functions are supported in DB2, Postgres, Oracle, SQL Server and Sybase.
@Support(value={POSTGRES,ORACLE,SYBASE}) public static WindowOverStep<BigDecimal> cumeDist()
cume_dist() over ([analytic clause])
function.
Window functions are supported in DB2, Postgres, Oracle, SQL Server and Sybase.
@Support(value={POSTGRES,ORACLE,SQLSERVER}) public static WindowOverStep<Integer> ntile(int number)
ntile([number]) over ([analytic clause])
function.
Window functions are supported in DB2, Postgres, Oracle, SQL Server and Sybase.
@Support(value={DB2,POSTGRES,ORACLE,SYBASE}) public static <T> WindowIgnoreNullsStep<T> firstValue(Field<T> field)
first_value(field) over ([analytic clause])
function.
Window functions are supported in DB2, Postgres, Oracle, SQL Server and Sybase.
@Support(value={DB2,POSTGRES,ORACLE,SYBASE}) public static <T> WindowIgnoreNullsStep<T> lastValue(Field<T> field)
last_value(field) over ([analytic clause])
function.
Window functions are supported in DB2, Postgres, Oracle, SQL Server and Sybase.
@Support(value={DB2,POSTGRES,ORACLE}) public static <T> WindowIgnoreNullsStep<T> lead(Field<T> field)
lead(field) over ([analytic clause])
function.
Window functions are supported in DB2, Postgres, Oracle, SQL Server and Sybase.
@Support(value={DB2,POSTGRES,ORACLE}) public static <T> WindowIgnoreNullsStep<T> lead(Field<T> field, int offset)
lead(field, offset) over ([analytic clause])
function.
Window functions are supported in DB2, Postgres, Oracle, SQL Server and Sybase.
@Support(value={DB2,POSTGRES,ORACLE}) public static <T> WindowIgnoreNullsStep<T> lead(Field<T> field, int offset, T defaultValue)
lead(field, offset, defaultValue) over ([analytic clause])
function.
Window functions are supported in DB2, Postgres, Oracle, SQL Server and Sybase.
@Support(value={DB2,POSTGRES,ORACLE}) public static <T> WindowIgnoreNullsStep<T> lead(Field<T> field, int offset, Field<T> defaultValue)
lead(field, offset, defaultValue) over ([analytic clause])
function.
Window functions are supported in DB2, Postgres, Oracle, SQL Server and Sybase.
@Support(value={DB2,POSTGRES,ORACLE}) public static <T> WindowIgnoreNullsStep<T> lag(Field<T> field)
lag(field) over ([analytic clause])
function.
Window functions are supported in DB2, Postgres, Oracle, SQL Server and Sybase.
@Support(value={DB2,POSTGRES,ORACLE}) public static <T> WindowIgnoreNullsStep<T> lag(Field<T> field, int offset)
lag(field, offset) over ([analytic clause])
function.
Window functions are supported in DB2, Postgres, Oracle, SQL Server and Sybase.
@Support(value={DB2,POSTGRES,ORACLE}) public static <T> WindowIgnoreNullsStep<T> lag(Field<T> field, int offset, T defaultValue)
lag(field, offset, defaultValue) over ([analytic clause])
function.
Window functions are supported in DB2, Postgres, Oracle, SQL Server and Sybase.
@Support(value={DB2,POSTGRES,ORACLE}) public static <T> WindowIgnoreNullsStep<T> lag(Field<T> field, int offset, Field<T> defaultValue)
lag(field, offset, defaultValue) over ([analytic clause])
function.
Window functions are supported in DB2, Postgres, Oracle, SQL Server and Sybase.
@Support public static Param<Object> param(String name)
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)
param(String, Object)
@Support public static <T> Param<T> param(String name, Class<? extends T> type)
param(String, Object)
@Support public static <T> Param<T> param(String name, DataType<T> type)
param(String, Object)
@Support public static <T> Param<T> param(String name, T value)
Named parameters are useful for several use-cases:
JdbcTemplate
, which
supports named parameters. Use
FactoryOperations.renderNamedParams(QueryPart)
to render
parameter names in SQLQuery.getParam(String)
and Query.getParams()
.@Support public static <T> Field<T> value(T value)
val(Object)
to be used in Scala and Groovy, where
val
is a reserved keyword.val(Object)
@Support public static <T> Field<T> value(Object value, Class<? extends T> type)
val(Object, Class)
to be used in Scala and Groovy, where
val
is a reserved keyword.val(Object, Class)
@Support public static <T> Field<T> value(Object value, Field<T> field)
val(Object, Field)
to be used in Scala and Groovy, where
val
is a reserved keyword.val(Object, Field)
@Support public static <T> Field<T> value(Object value, DataType<T> type)
val(Object, DataType)
to be used in Scala and Groovy, where
val
is a reserved keyword.val(Object, DataType)
@Support public static <T> Param<T> inline(T value)
The resulting bind value is always inlined, regardless of the
Settings.getStatementType()
property of the rendering factory.
Unlike with field(String)
, you can expect value
to
be properly escaped for SQL syntax correctness and SQL injection
prevention. For example:
inline("abc'def")
renders 'abc''def'
field("abc'def")
renders abc'def
val(Object)
@Support public static Param<String> inline(char character)
This is a convenience method for inline(Object)
, returning
Field<String>
, rather than
Field<Character>
inline(Object)
@Support public static Param<String> inline(Character character)
This is a convenience method for inline(Object)
, returning
Field<String>
, rather than
Field<Character>
inline(Object)
@Support public static Param<String> inline(CharSequence character)
This is a convenience method for inline(Object)
, returning
Field<String>
, rather than
Field<CharSequence>
inline(Object)
@Support public static <T> Param<T> inline(Object value, Class<? extends T> type)
The resulting bind value is always inlined, regardless of the
Settings.getStatementType()
property of the rendering factory.
Unlike with field(String, Class)
, you can expect
value
to be properly escaped for SQL syntax correctness and
SQL injection prevention. For example:
inline("abc'def")
renders 'abc''def'
field("abc'def")
renders abc'def
val(Object, Class)
@Support public static <T> Param<T> inline(Object value, Field<T> field)
The resulting bind value is always inlined, regardless of the
Settings.getStatementType()
property of the rendering factory.
Unlike with field(String, DataType)
, you can expect
value
to be properly escaped for SQL syntax correctness and
SQL injection prevention. For example:
inline("abc'def")
renders 'abc''def'
field("abc'def")
renders abc'def
val(Object, Field)
@Support public static <T> Param<T> inline(Object value, DataType<T> type)
The resulting bind value is always inlined, regardless of the
Settings.getStatementType()
property of the rendering factory.
Unlike with field(String, DataType)
, you can expect
value
to be properly escaped for SQL syntax correctness and
SQL injection prevention. For example:
inline("abc'def")
renders 'abc''def'
field("abc'def")
renders abc'def
val(Object, DataType)
@Support public static <T> Field<T> val(T 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.
T
- The generic value typevalue
- The constant value@Support public static <T> Field<T> val(Object value, Class<? extends T> type)
T
- The generic value typevalue
- The constant valuetype
- The data type to enforce upon the valueval(Object, DataType)
@Support public static <T> Field<T> val(Object value, Field<T> field)
T
- The generic value typevalue
- The constant valuefield
- The field whose data type to enforce upon the valueval(Object, DataType)
@Support public static <T> Field<T> val(Object value, DataType<T> 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
.
T
- The generic value typevalue
- The constant valuetype
- The data type to enforce upon the value@Support public static List<Field<?>> vals(Object... values)
@Support public static <T1> Row1<T1> row(T1 t1)
1
Note: Not all databases support row value expressions, but many row value expression operations can be simulated on all databases. See relevant row value expression method Javadocs for details.
@Support public static <T1,T2> Row2<T1,T2> row(T1 t1, T2 t2)
2
Note: Not all databases support row value expressions, but many row value expression operations can be simulated on all databases. See relevant row value expression method Javadocs for details.
@Support public static <T1,T2,T3> Row3<T1,T2,T3> row(T1 t1, T2 t2, T3 t3)
3
Note: Not all databases support row value expressions, but many row value expression operations can be simulated on all databases. See relevant row value expression method Javadocs for details.
@Support public static <T1,T2,T3,T4> Row4<T1,T2,T3,T4> row(T1 t1, T2 t2, T3 t3, T4 t4)
4
Note: Not all databases support row value expressions, but many row value expression operations can be simulated on all databases. See relevant row value expression method Javadocs for details.
@Support public static <T1,T2,T3,T4,T5> Row5<T1,T2,T3,T4,T5> row(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5)
5
Note: Not all databases support row value expressions, but many row value expression operations can be simulated on all databases. See relevant row value expression method Javadocs for details.
@Support public static <T1,T2,T3,T4,T5,T6> Row6<T1,T2,T3,T4,T5,T6> row(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6)
6
Note: Not all databases support row value expressions, but many row value expression operations can be simulated on all databases. See relevant row value expression method Javadocs for details.
@Support public static <T1,T2,T3,T4,T5,T6,T7> Row7<T1,T2,T3,T4,T5,T6,T7> row(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7)
7
Note: Not all databases support row value expressions, but many row value expression operations can be simulated on all databases. See relevant row value expression method Javadocs for details.
@Support public static <T1,T2,T3,T4,T5,T6,T7,T8> Row8<T1,T2,T3,T4,T5,T6,T7,T8> row(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8)
8
Note: Not all databases support row value expressions, but many row value expression operations can be simulated on all databases. See relevant row value expression method Javadocs for details.
@Support public static RowN row(Object... values)
N > 8
Note: Not all databases support row value expressions, but many row value expression operations can be simulated on all databases. See relevant row value expression method Javadocs for details.
@Support public static <T1> Row1<T1> row(Field<T1> t1)
1
Note: Not all databases support row value expressions, but many row value expression operations can be simulated on all databases. See relevant row value expression method Javadocs for details.
@Support public static <T1,T2> Row2<T1,T2> row(Field<T1> t1, Field<T2> t2)
2
Note: Not all databases support row value expressions, but many row value expression operations can be simulated on all databases. See relevant row value expression method Javadocs for details.
@Support public static <T1,T2,T3> Row3<T1,T2,T3> row(Field<T1> t1, Field<T2> t2, Field<T3> t3)
3
Note: Not all databases support row value expressions, but many row value expression operations can be simulated on all databases. See relevant row value expression method Javadocs for details.
@Support public static <T1,T2,T3,T4> Row4<T1,T2,T3,T4> row(Field<T1> t1, Field<T2> t2, Field<T3> t3, Field<T4> t4)
4
Note: Not all databases support row value expressions, but many row value expression operations can be simulated on all databases. See relevant row value expression method Javadocs for details.
@Support public static <T1,T2,T3,T4,T5> Row5<T1,T2,T3,T4,T5> row(Field<T1> t1, Field<T2> t2, Field<T3> t3, Field<T4> t4, Field<T5> t5)
5
Note: Not all databases support row value expressions, but many row value expression operations can be simulated on all databases. See relevant row value expression method Javadocs for details.
@Support public static <T1,T2,T3,T4,T5,T6> Row6<T1,T2,T3,T4,T5,T6> row(Field<T1> t1, Field<T2> t2, Field<T3> t3, Field<T4> t4, Field<T5> t5, Field<T6> t6)
6
Note: Not all databases support row value expressions, but many row value expression operations can be simulated on all databases. See relevant row value expression method Javadocs for details.
@Support public static <T1,T2,T3,T4,T5,T6,T7> Row7<T1,T2,T3,T4,T5,T6,T7> row(Field<T1> t1, Field<T2> t2, Field<T3> t3, Field<T4> t4, Field<T5> t5, Field<T6> t6, Field<T7> t7)
7
Note: Not all databases support row value expressions, but many row value expression operations can be simulated on all databases. See relevant row value expression method Javadocs for details.
@Support public static <T1,T2,T3,T4,T5,T6,T7,T8> Row8<T1,T2,T3,T4,T5,T6,T7,T8> row(Field<T1> t1, Field<T2> t2, Field<T3> t3, Field<T4> t4, Field<T5> t5, Field<T6> t6, Field<T7> t7, Field<T8> t8)
8
Note: Not all databases support row value expressions, but many row value expression operations can be simulated on all databases. See relevant row value expression method Javadocs for details.
@Support public static RowN row(Field<?>... values)
N > 8
Note: Not all databases support row value expressions, but many row value expression operations can be simulated on all databases. See relevant row value expression method Javadocs for details.
@Deprecated @Support public static <T> Field<T> literal(T literal)
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!
T
- The generic field typeliteral
- The literal@Deprecated @Support public static <T> Field<T> literal(Object literal, Class<T> type)
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!
T
- The generic field typeliteral
- The literaltype
- The literal's data type@Deprecated @Support public static <T> Field<T> literal(Object literal, DataType<T> type)
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!
T
- The generic field typeliteral
- The literaltype
- The literal's data typeprotected static <T> DataType<T> nullSafeDataType(Field<T> field)
@Support public static Field<Integer> zero()
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.
0
literal as a Field
@Support public static Field<Integer> one()
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.
1
literal as a Field
@Support public static Field<Integer> two()
2
literal.
This is useful for mathematical functions. The 1
literal
will not generate a bind variable.
2
literal as a Field
@Support public static Field<BigDecimal> pi()
PI
literal.
This will be any of the following:
PI
literal or PI()
functionMath.PI
@Support public static Field<BigDecimal> e()
E
literal (Euler number)
This will be any of the following:
E
literal or E()
functionMath.E
@Support(value={ASE,CUBRID,DB2,DERBY,FIREBIRD,H2,HSQLDB,INGRES,MYSQL,ORACLE,POSTGRES,SQLSERVER,SYBASE}) public static Field<String> currentUser()
This translates into any dialect
public final <R extends Record> Result<R> fetch(Table<R> table)
SELECT * FROM [table]
The result and its contained records are attached to this
Configuration
by default. Use Settings.isAttachRecords()
to override this behaviour.
fetch
in interface FactoryOperations
public final <R extends Record> Result<R> fetch(Table<R> table, Condition condition)
SELECT * FROM [table] WHERE [condition]
The result and its contained records are attached to this
Configuration
by default. Use Settings.isAttachRecords()
to override this behaviour.
fetch
in interface FactoryOperations
public final <R extends Record> R fetchOne(Table<R> table)
SELECT * FROM [table]
The resulting record is attached to this Configuration
by
default. Use Settings.isAttachRecords()
to override this
behaviour.
fetchOne
in interface FactoryOperations
null
if no record was returnedpublic final <R extends Record> R fetchOne(Table<R> table, Condition condition)
SELECT * FROM [table] WHERE [condition]
The resulting record is attached to this Configuration
by
default. Use Settings.isAttachRecords()
to override this
behaviour.
fetchOne
in interface FactoryOperations
null
if no record was returnedpublic final <R extends Record> R fetchAny(Table<R> table)
SELECT * FROM [table] LIMIT 1
The resulting record is attached to this Configuration
by
default. Use Settings.isAttachRecords()
to override this
behaviour.
fetchAny
in interface FactoryOperations
null
if no record was returned@Deprecated public final <R extends TableRecord<R>> int executeInsert(Table<R> table, R record)
INSERT INTO [table] ... VALUES [record]
executeInsert
in interface FactoryOperations
public final <R extends TableRecord<R>> int executeInsert(R record)
This executes something like the following statement:
INSERT INTO [table] ... VALUES [record]
Unlike UpdatableRecord.store()
, this does not change any of the
argument record
's internal "changed" flags, such that a
subsequent call to UpdatableRecord.store()
might lead to another
INSERT
statement being executed.
executeInsert
in interface FactoryOperations
@Deprecated public final <R extends TableRecord<R>> int executeUpdate(Table<R> table, R record)
UPDATE [table] SET [modified values in record]
executeUpdate
in interface FactoryOperations
@Deprecated public final <R extends TableRecord<R>,T> int executeUpdate(Table<R> table, R record, Condition condition)
UPDATE [table] SET [modified values in record] WHERE [condition]
executeUpdate
in interface FactoryOperations
@Deprecated public final <R extends TableRecord<R>> int executeUpdateOne(Table<R> table, R record)
UPDATE [table] SET [modified values in record]
executeUpdateOne
in interface FactoryOperations
@Deprecated public final <R extends TableRecord<R>,T> int executeUpdateOne(Table<R> table, R record, Condition condition)
UPDATE [table] SET [modified values in record] WHERE [condition]
executeUpdateOne
in interface FactoryOperations
public final <R extends UpdatableRecord<R>> int executeUpdate(R record)
UPDATE [table] SET [modified values in record] WHERE [record is supplied record]
executeUpdate
in interface FactoryOperations
public final <R extends TableRecord<R>,T> int executeUpdate(R record, Condition condition)
UPDATE [table] SET [modified values in record] WHERE [condition]
executeUpdate
in interface FactoryOperations
public final <R extends UpdatableRecord<R>> int executeDelete(R record)
DELETE FROM [table] WHERE [record is supplied record]
executeDelete
in interface FactoryOperations
public final <R extends TableRecord<R>,T> int executeDelete(R record, Condition condition)
DELETE FROM [table] WHERE [condition]
executeDelete
in interface FactoryOperations
@Deprecated public final <R extends TableRecord<R>> int executeDelete(Table<R> table)
DELETE FROM [table]
executeDelete
in interface FactoryOperations
@Deprecated public final <R extends TableRecord<R>,T> int executeDelete(Table<R> table, Condition condition) throws DataAccessException
DELETE FROM [table] WHERE [condition]
executeDelete
in interface FactoryOperations
DataAccessException
- if something went wrong executing the query.@Deprecated public final <R extends TableRecord<R>> int executeDeleteOne(Table<R> table)
DELETE FROM [table]
executeDeleteOne
in interface FactoryOperations
@Deprecated public final <R extends TableRecord<R>,T> int executeDeleteOne(Table<R> table, Condition condition)
DELETE FROM [table] WHERE [condition]
executeDeleteOne
in interface FactoryOperations
@Support public static <T> DataType<T> getDataType(Class<? extends T> type)
Factory
's underlying
SQLDialect
and a given Java type.
This is a convenience method for calling
FieldTypeHelper.getDataType(SQLDialect, Class)
T
- The generic typetype
- The Java typeFactory
's underlying default data type.Copyright © 2013. All Rights Reserved.