org.jooq
Interface FactoryOperations

All Superinterfaces:
Configuration, Serializable
All Known Implementing Classes:
ASEFactory, CUBRIDFactory, DB2Factory, DerbyFactory, Factory, H2Factory, HSQLDBFactory, IngresFactory, MySQLFactory, OracleFactory, PostgresFactory, SQLiteFactory, SQLServerFactory, SybaseFactory

public interface FactoryOperations
extends Configuration

The public API for the jOOQ Factory

Author:
Sergey Epik, Lukas Eder
See Also:
Factory

Method Summary
 void attach(Attachable... attachables)
          Attach this Factory to some attachables
 void attach(Collection<Attachable> attachables)
          Attach this Factory to some attachables
 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).
<T extends Number>
T
currval(Sequence<T> sequence)
          Convenience method to fetch the CURRVAL for a sequence directly from this Factory's underlying JDBC Connection
<R extends Record>
DeleteWhereStep<R>
delete(Table<R> table)
          Create a new DSL delete statement.
<R extends Record>
DeleteQuery<R>
deleteQuery(Table<R> table)
          Create a new DeleteQuery
 int execute(String sql)
          Execute a query holding plain SQL.
 int execute(String sql, Object... bindings)
          Execute a new query holding plain SQL.
<R extends TableRecord<R>>
int
executeDelete(Table<R> table)
          Delete records from a table DELETE FROM [table]
<R extends TableRecord<R>,T>
int
executeDelete(Table<R> table, Condition condition)
          Delete records from a table DELETE FROM [table] WHERE [condition]
<R extends TableRecord<R>>
int
executeDeleteOne(Table<R> table)
          Delete one record in a table DELETE FROM [table]
<R extends TableRecord<R>,T>
int
executeDeleteOne(Table<R> table, Condition condition)
          Delete one record in a table DELETE FROM [table] WHERE [condition]
<R extends TableRecord<R>>
int
executeInsert(Table<R> table, R record)
          Insert one record INSERT INTO [table] ...
<R extends TableRecord<R>>
int
executeUpdate(Table<R> table, R record)
          Update a table UPDATE [table] SET [modified values in record]
<R extends TableRecord<R>,T>
int
executeUpdate(Table<R> table, R record, Condition condition)
          Update a table UPDATE [table] SET [modified values in record] WHERE [condition]
<R extends TableRecord<R>>
int
executeUpdateOne(Table<R> table, R record)
          Update one record in a table UPDATE [table] SET [modified values in record]
<R extends TableRecord<R>,T>
int
executeUpdateOne(Table<R> table, R record, Condition condition)
          Update one record in a table UPDATE [table] SET [modified values in record] WHERE [condition]
 Result<Record> fetch(ResultSet rs)
          Fetch all data from a JDBC ResultSet and transform it to a jOOQ Result.
 Result<Record> fetch(String sql)
          Execute a new query holding plain SQL.
 Result<Record> fetch(String sql, Object... bindings)
          Execute a new query holding plain SQL.
<R extends Record>
Result<R>
fetch(Table<R> table)
          Execute and return all records for SELECT * FROM [table]
<R extends Record>
Result<R>
fetch(Table<R> table, Condition condition)
          Execute and return all records for SELECT * FROM [table] WHERE [condition]
<R extends Record>
R
fetchAny(Table<R> table)
          Execute and return zero or one record for SELECT * FROM [table] LIMIT 1
 Cursor<Record> fetchLazy(String sql)
          Execute a new query holding plain SQL and "lazily" return the generated result.
 Cursor<Record> fetchLazy(String sql, Object... bindings)
          Execute a new query holding plain SQL and "lazily" return the generated result.
 List<Result<Record>> fetchMany(String sql)
          Execute a new query holding plain SQL, possibly returning several result sets Example (Sybase ASE): String sql = "sp_help 'my_table'"; NOTE: When inserting plain SQL into jOOQ objects, you must guarantee syntax integrity.
 List<Result<Record>> fetchMany(String sql, Object... bindings)
          Execute a new query holding plain SQL, possibly returning several result sets.
 Record fetchOne(String sql)
          Execute a new query holding plain SQL.
 Record fetchOne(String sql, Object... bindings)
          Execute a new query holding plain SQL.
<R extends Record>
R
fetchOne(Table<R> table)
          Execute and return zero or one record for SELECT * FROM [table]
<R extends Record>
R
fetchOne(Table<R> table, Condition condition)
          Execute and return zero or one record for SELECT * FROM [table] WHERE [condition]
<R extends Record>
InsertSetStep<R>
insertInto(Table<R> into)
          Create a new DSL insert statement.
<R extends Record>
InsertValuesStep<R>
insertInto(Table<R> into, Collection<? extends Field<?>> fields)
          Create a new DSL insert statement.
<R extends Record>
InsertValuesStep<R>
insertInto(Table<R> into, Field<?>... fields)
          Create a new DSL insert statement.
<R extends Record>
Insert<R>
insertInto(Table<R> into, Select<?> select)
          Deprecated. - 2.0.3 - Use any of these methods instead:
<R extends Record>
InsertQuery<R>
insertQuery(Table<R> into)
          Create a new InsertQuery
 BigInteger lastID()
          Retrieve the last inserted ID.
<R extends TableRecord<R>>
LoaderOptionsStep<R>
loadInto(Table<R> table)
          Create a new Loader object to load data from a CSV or XML source
<R extends Record>
MergeUsingStep<R>
mergeInto(Table<R> table)
          Create a new DSL merge statement.
<R extends TableRecord<R>>
R
newRecord(Table<R> table)
          Create a new Record that can be inserted into the corresponding table.
<R extends TableRecord<R>>
R
newRecord(Table<R> table, Object source)
          Create a new pre-filled Record that can be inserted into the corresponding table.
<R extends UDTRecord<R>>
R
newRecord(UDT<R> type)
          Create a new attached UDTRecord.
<T extends Number>
T
nextval(Sequence<T> sequence)
          Convenience method to fetch the NEXTVAL for a sequence directly from this Factory's underlying JDBC Connection
 Query query(String sql)
          Create a new query holding plain SQL.
 Query query(String sql, Object... bindings)
          Create a new query holding plain SQL.
 String render(QueryPart part)
          Render a QueryPart in the context of this factory This is the same as calling renderContext().render(part)
 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.
 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.
 SelectSelectStep select(Collection<? extends Field<?>> fields)
          Create a new DSL select statement.
 SelectSelectStep select(Field<?>... fields)
          Create a new DSL select statement.
 SelectSelectStep selectCount()
          Create a new DSL select statement for COUNT(*) Example: Factory create = new Factory(); create.selectCount() .from(table1) .join(table2).on(field1.equal(field2)) .where(field1.greaterThan(100)) .orderBy(field2) .execute();
 SelectSelectStep selectDistinct(Collection<? extends Field<?>> fields)
          Create a new DSL select statement.
 SelectSelectStep selectDistinct(Field<?>... fields)
          Create a new DSL select statement.
<R extends Record>
SimpleSelectWhereStep<R>
selectFrom(Table<R> table)
          Create a new DSL select statement Example: SELECT * FROM [table] WHERE [conditions] ORDER BY [ordering] LIMIT [limit clause]
 SelectSelectStep selectOne()
          Create a new DSL select statement for constant 1 literal Example: Factory create = new Factory(); create.selectOne() .from(table1) .join(table2).on(field1.equal(field2)) .where(field1.greaterThan(100)) .orderBy(field2) .execute();
 SelectQuery selectQuery()
          Create a new SelectQuery
<R extends Record>
SimpleSelectQuery<R>
selectQuery(TableLike<R> table)
          Create a new SelectQuery
 SelectSelectStep selectZero()
          Create a new DSL select statement for constant 0 literal Example: Factory create = new Factory(); create.selectZero() .from(table1) .join(table2).on(field1.equal(field2)) .where(field1.greaterThan(100)) .orderBy(field2) .execute();
<R extends TableRecord<R>>
Truncate<R>
truncate(Table<R> table)
          Create a new DSL truncate statement.
<R extends Record>
UpdateSetStep<R>
update(Table<R> table)
          Create a new DSL update statement.
<R extends Record>
UpdateQuery<R>
updateQuery(Table<R> table)
          Create a new UpdateQuery
 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.
 
Methods inherited from interface org.jooq.Configuration
getConnection, getData, getData, getDialect, getSchemaMapping, getSettings, setConnection, setData
 

Method Detail

render

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

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

Parameters:
part - The QueryPart to be rendered
Returns:
The rendered SQL

renderNamedParams

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

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

Parameters:
part - The QueryPart to be rendered
Returns:
The rendered SQL

renderInlined

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

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

Parameters:
part - The QueryPart to be rendered
Returns:
The rendered SQL

attach

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


attach

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


loadInto

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


query

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

Example:

 String sql = "SET SCHEMA 'abc'";

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

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

query

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

Example:

 String sql = "SET SCHEMA 'abc'";

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

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

fetch

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

Parameters:
rs - The JDBC ResultSet to fetch data from
Returns:
The resulting jOOQ Result
Throws:
DataAccessException - if something went wrong executing the query

selectFrom

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

Example:

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


select

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

Example:

 Factory create = new Factory();

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


selectZero

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

Example:

 Factory create = new Factory();

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

See Also:
Factory.zero()

selectOne

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

Example:

 Factory create = new Factory();

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

See Also:
Factory.one()

selectCount

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

Example:

 Factory create = new Factory();

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


selectDistinct

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

Example:

 Factory create = new Factory();

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


select

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

Example:

 Factory create = new Factory();

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


selectDistinct

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

Example:

 Factory create = new Factory();

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


selectQuery

SelectQuery selectQuery()
Create a new SelectQuery


selectQuery

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

Parameters:
table - The table to select data from
Returns:
The new SelectQuery

insertQuery

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

Parameters:
into - The table to insert data into
Returns:
The new InsertQuery

insertInto

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

Example:

 Factory create = new Factory();

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


insertInto

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

Example:

 Factory create = new Factory();

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


insertInto

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

Example:

 Factory create = new Factory();

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


insertInto

@Deprecated
<R extends Record> Insert<R> insertInto(Table<R> into,
                                                   Select<?> select)
Deprecated. - 2.0.3 - Use any of these methods instead:

Create a new DSL insert statement.

Example:

 Factory create = new Factory();

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


updateQuery

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

Parameters:
table - The table to update data into
Returns:
The new UpdateQuery

update

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

Example:

 Factory create = new Factory();

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


mergeInto

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

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

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

Example:

 Factory create = new Factory();

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


deleteQuery

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

Parameters:
table - The table to delete data from
Returns:
The new DeleteQuery

delete

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

Example:

 Factory create = new Factory();

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


batch

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

This essentially runs the following logic:

 Statement s = connection.createStatement();

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

 s.execute();
 

See Also:
Statement.executeBatch()

batch

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

This essentially runs the following logic:

 Statement s = connection.createStatement();

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

 s.execute();
 

See Also:
Statement.executeBatch()

batch

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

When running

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

This essentially runs the following logic:

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

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

     s.addBatch();
 }

 s.execute();
 

See Also:
Statement.executeBatch()

truncate

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

Example:

 Factory create = new Factory();

 create.truncate(table)
       .execute();
 

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

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


lastID

BigInteger lastID()
                  throws DataAccessException
Retrieve the last inserted ID.

Note, there are some restrictions to the following dialects:

Returns:
The last inserted ID. This may be null in some dialects, if no such number is available.
Throws:
DataAccessException - if something went wrong executing the query

nextval

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

Throws:
DataAccessException - if something went wrong executing the query

currval

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

Throws:
DataAccessException - if something went wrong executing the query

use

int use(Schema schema)
        throws DataAccessException
Use a schema as the default schema of the underlying connection.

This has two effects.

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

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

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

Throws:
DataAccessException - if something went wrong executing the query

use

int use(String schema)
        throws DataAccessException
Use a schema as the default schema of the underlying connection.

Throws:
DataAccessException - if something went wrong executing the query
See Also:
use(Schema)

newRecord

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

Type Parameters:
R - The generic record type
Parameters:
type - The UDT describing records of type <R>
Returns:
The new record

newRecord

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

Type Parameters:
R - The generic record type
Parameters:
table - The table holding records of type <R>
Returns:
The new record

newRecord

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

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

Type Parameters:
R - The generic record type
Parameters:
table - The table holding records of type <R>
source - The source to be used to fill the new record
Returns:
The new record
Throws:
MappingException - wrapping any reflection or data type conversion exception that might have occurred while mapping records
See Also:
Record.from(Object), Record.into(Class)

fetch

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

Throws:
DataAccessException - if something went wrong executing the query

fetch

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

Throws:
DataAccessException - if something went wrong executing the query

fetchOne

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

Returns:
The record or null if no record was returned
Throws:
DataAccessException - if something went wrong executing the query

fetchOne

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

Returns:
The record or null if no record was returned
Throws:
DataAccessException - if something went wrong executing the query

fetchAny

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

Returns:
The record or null if no record was returned
Throws:
DataAccessException - if something went wrong executing the query

executeInsert

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

Returns:
The number of inserted records
Throws:
DataAccessException - if something went wrong executing the query

executeUpdate

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

Returns:
The number of updated records
Throws:
DataAccessException - if something went wrong executing the query

executeUpdate

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

Returns:
The number of updated records
Throws:
DataAccessException - if something went wrong executing the query

executeUpdateOne

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

Returns:
The number of updated records
Throws:
DataAccessException - if something went wrong executing the query

executeUpdateOne

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

Returns:
The number of updated records
Throws:
DataAccessException - if something went wrong executing the query

executeDelete

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

Returns:
The number of deleted records
Throws:
DataAccessException - if something went wrong executing the query

executeDelete

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

Returns:
The number of deleted records
Throws:
DataAccessException - if something went wrong executing the query

executeDeleteOne

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

Returns:
The number of deleted records
Throws:
DataAccessException - if something went wrong executing the query

executeDeleteOne

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

Returns:
The number of deleted records
Throws:
DataAccessException - if something went wrong executing the query

fetch

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

Example (Postgres):

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

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

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

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

fetch

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

Example (Postgres):

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

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

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

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

fetchLazy

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

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

Example (Postgres):

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

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

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

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

fetchLazy

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

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

Example (Postgres):

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

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

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

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

fetchMany

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

Example (Sybase ASE):

 String sql = "sp_help 'my_table'";

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

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

fetchMany

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

Example (Sybase ASE):

 String sql = "sp_help 'my_table'";

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

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

fetchOne

Record fetchOne(String sql)
                throws DataAccessException
Execute a new query holding plain SQL.

Example (Postgres):

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

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

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

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

fetchOne

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

Example (Postgres):

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

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

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

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

execute

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

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

Parameters:
sql - The SQL
Returns:
The results from the executed query
Throws:
DataAccessException - if something went wrong executing the query

execute

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

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

Parameters:
sql - The SQL
bindings - The bindings
Returns:
The results from the executed query
Throws:
DataAccessException - if something went wrong executing the query

resultQuery

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

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

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

Example (Postgres):

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

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

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

Parameters:
sql - The SQL
Returns:
An executable query
Throws:
DataAccessException - if something went wrong executing the query

resultQuery

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

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

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

Example (Postgres):

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

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

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

Parameters:
sql - The SQL
bindings - The bindings
Returns:
An executable query
Throws:
DataAccessException - if something went wrong executing the query


Copyright © 2012. All Rights Reserved.