Top Description Methods
org.jooq

public Interface DAO<R extends org.jooq.TableRecord<R>, P, T>

Known Direct Implementers
org.jooq.impl.DAOImpl
Annotations
@Blocking
Type Parameters
<R>
The generic record type.
<P>
The generic POJO type.
<T>
The generic primary key type. This is a regular <T> type for single-column keys, or a Record subtype for composite keys.
Static Imports
org.jooq.SQLDialect.CUBRID, .SQLDialect.DERBY, .SQLDialect.H2, .SQLDialect.HSQLDB, .SQLDialect.MARIADB, .SQLDialect.MYSQL, .SQLDialect.POSTGRES, .SQLDialect.SQLITE

A generic DAO interface for a pojo and a primary key type.

This type is implemented by generated DAO classes to provide a common API for common actions on POJOs

Author
Lukas Eder

Method Summary

Modifier and TypeMethod and Description
public @NotNull Configuration

Returns:

the DAO's underlying Configuration
configuration
()

Expose the configuration in whose context this DAO is operating.

public long

Returns:

The number of records of the underlying table
count
()

Count all records of the underlying table.

public void
delete(P
The POJO to be deleted
object
)

Performs a DELETE statement for a POJO

public void
delete(P...
The POJOs to be deleted
objects
)

Performs a DELETE statement for a given set of POJOs.

public void
delete(Collection<P>
The POJOs to be deleted
objects
)

Performs a DELETE statement for a given set of POJOs.

public void
deleteById(T
The IDs to be deleted
id
)

Performs a DELETE statement for a given set of IDs.

public void
deleteById(T...
The IDs to be deleted
ids
)

Performs a DELETE statement for a given set of IDs.

public void
deleteById(Collection<T>
The IDs to be deleted
ids
)

Performs a DELETE statement for a given set of IDs.

public @NotNull SQLDialect
dialect()

The SQLDialect wrapped by this context.

public boolean

Returns:

Whether the POJO already exists
exists
(P
The POJO whose existence is checked
object
)

Checks if a given POJO exists.

public boolean

Returns:

Whether the ID already exists
existsById
(T
The ID whose existence is checked
id
)

Checks if a given ID exists.

public @NotNull SQLDialect
family()

The SQLDialect#family() wrapped by this context.

public <Z> @NotNull List<P>

Returns:

A list of records fulfilling field IN (values)
fetch
(Field<Z>
The field to compare values against
field
,
Z...
The accepted values
values
)

Deprecated as a consequence of Field being deprecated.
Find records by a given field and a set of values.
public <Z> @NotNull List<P>

Returns:

A list of records fulfilling field IN (values)
fetch
(Field<Z>
The field to compare values against
field
,
Collection<? extends Z>
The accepted values
values
)

Deprecated as a consequence of Field being deprecated.
Find records by a given field and a set of values.
public <Z> P

Returns:

A record fulfilling field = value, or null
fetchOne
(Field<Z>
The field to compare value against
field
,
Z
The accepted value
value
)

Deprecated as a consequence of Field being deprecated.
Find a unique record by a given field and a value.
public <Z> @NotNull Optional<@NotNull P>

Returns:

A record fulfilling field = value
fetchOptional
(Field<Z>
The field to compare value against
field
,
Z
The accepted value
value
)

Deprecated as a consequence of Field being deprecated.
Find a unique record by a given field and a value.
public <Z> @NotNull List<P>

Returns:

A list of records fulfilling field BETWEEN lowerInclusive AND upperInclusive
fetchRange
(Field<Z>
The field to compare values against
field
,
Z
The range's lower bound (inclusive), or unbounded if null.
lowerInclusive
,
Z
The range's upper bound (inclusive), or unbounded if null.
upperInclusive
)

Deprecated as a consequence of Field being deprecated.
Find records by a given field and a range of values.
public @NotNull List<@NotNull P>

Returns:

All records of the underlying table
findAll
()

Find all records of the underlying table.

public P

Returns:

A record of the underlying table given its ID, or null if no record was found.
findById
(T
The ID of a record in the underlying table
id
)

Find a record of the underlying table by ID.

public @NotNull Optional<@NotNull P>

Returns:

A record of the underlying table given its ID.
findOptionalById
(T
The ID of a record in the underlying table
id
)

Find a record of the underlying table by ID.

public T
getId(P object)

Extract the ID value from a POJO.

public @NotNull Table<R>
getTable()

Get the underlying table.

public @NotNull Class<P>
getType()

Get the underlying POJO type.

public void
insert(P
The POJO to be inserted
object
)

Performs an INSERT statement for a given POJO.

public void
insert(P...
The POJOs to be inserted
objects
)

Performs a batch INSERT statement for a given set of POJOs.

public void
insert(Collection<P>
The POJOs to be inserted
objects
)

Performs a batch INSERT statement for a given set of POJOs.

public @NotNull RecordMapper<R, P>

Returns:

the DAO's underlying RecordMapper
mapper
()

Expose the RecordMapper that is used internally by this DAO to map from records of type R to POJOs of type P.

public void
merge(P
The POJO to be merged
object
)

Performs an MERGE statement for a given POJO.

public void
merge(P...
The POJOs to be merged
objects
)

Performs a batch MERGE statement for a given set of POJOs.

public void
merge(Collection<P>
The POJOs to be merged
objects
)

Performs a batch MERGE statement for a given set of POJOs.

public @NotNull Settings
settings()

The settings wrapped by this context.

public void
update(P
The POJO to be updated
object
)

Performs an UPDATE statement for a given POJO.

public void
update(P...
The POJOs to be updated
objects
)

Performs a batch UPDATE statement for a given set of POJOs.

public void
update(Collection<P>
The POJOs to be updated
objects
)

Performs a batch UPDATE statement for a given set of POJOs.

Method Detail

configurationback to summary
public @NotNull Configuration configuration()

Expose the configuration in whose context this DAO is operating.

Returns:@NotNull Configuration

the DAO's underlying Configuration

Annotations
@NotNull
countback to summary
public long count() throws DataAccessException

Count all records of the underlying table.

Returns:long

The number of records of the underlying table

Annotations
@Support
Exceptions
DataAccessException:
if something went wrong executing the query
deleteback to summary
public void delete(P object) throws DataAccessException

Performs a DELETE statement for a POJO

Parameters
object:P

The POJO to be deleted

Annotations
@Support
Exceptions
DataAccessException:
if something went wrong executing the query
See Also
delete(Collection)
deleteback to summary
public void delete(P... objects) throws DataAccessException

Performs a DELETE statement for a given set of POJOs.

Parameters
objects:P[]

The POJOs to be deleted

Annotations
@Support
Exceptions
DataAccessException:
if something went wrong executing the query
See Also
delete(Collection)
deleteback to summary
public void delete(Collection<P> objects) throws DataAccessException

Performs a DELETE statement for a given set of POJOs.

Parameters
objects:Collection<P>

The POJOs to be deleted

Annotations
@Support
Exceptions
DataAccessException:
if something went wrong executing the query
See Also
delete(Object...)
deleteByIdback to summary
public void deleteById(T id) throws DataAccessException

Performs a DELETE statement for a given set of IDs.

Parameters
id:T

The IDs to be deleted

Annotations
@Support
Exceptions
DataAccessException:
if something went wrong executing the query
See Also
delete(Collection)
deleteByIdback to summary
public void deleteById(T... ids) throws DataAccessException

Performs a DELETE statement for a given set of IDs.

Parameters
ids:T[]

The IDs to be deleted

Annotations
@Support
Exceptions
DataAccessException:
if something went wrong executing the query
See Also
delete(Collection)
deleteByIdback to summary
public void deleteById(Collection<T> ids) throws DataAccessException

Performs a DELETE statement for a given set of IDs.

Parameters
ids:Collection<T>

The IDs to be deleted

Annotations
@Support
Exceptions
DataAccessException:
if something went wrong executing the query
See Also
delete(Object...)
dialectback to summary
public @NotNull SQLDialect dialect()

The SQLDialect wrapped by this context.

This method is a convenient way of accessing configuration().dialect().

Annotations
@NotNull
existsback to summary
public boolean exists(P object) throws DataAccessException

Checks if a given POJO exists.

Parameters
object:P

The POJO whose existence is checked

Returns:boolean

Whether the POJO already exists

Annotations
@Support
Exceptions
DataAccessException:
if something went wrong executing the query
existsByIdback to summary
public boolean existsById(T id) throws DataAccessException

Checks if a given ID exists.

Parameters
id:T

The ID whose existence is checked

Returns:boolean

Whether the ID already exists

Annotations
@Support
Exceptions
DataAccessException:
if something went wrong executing the query
familyback to summary
public @NotNull SQLDialect family()

The SQLDialect#family() wrapped by this context.

This method is a convenient way of accessing configuration().family().

Annotations
@NotNull
fetchback to summary
public <Z> @NotNull List<P> fetch(Field<Z> field, Z... values) throws DataAccessException

Deprecated

as a consequence of Field being deprecated. See corresponding docs for further information.

Find records by a given field and a set of values.

Parameters
field:Field<Z>

The field to compare values against

values:Z[]

The accepted values

Returns:@NotNull List<P>

A list of records fulfilling field IN (values)

Annotations
@NotNull
@Support
Exceptions
DataAccessException:
if something went wrong executing the query
fetchback to summary
public <Z> @NotNull List<P> fetch(Field<Z> field, Collection<? extends Z> values) throws DataAccessException

Deprecated

as a consequence of Field being deprecated. See corresponding docs for further information.

Find records by a given field and a set of values.

Parameters
field:Field<Z>

The field to compare values against

values:Collection<? extends Z>

The accepted values

Returns:@NotNull List<P>

A list of records fulfilling field IN (values)

Annotations
@NotNull
@Support
Exceptions
DataAccessException:
if something went wrong executing the query
fetchOneback to summary
public <Z> P fetchOne(Field<Z> field, Z value) throws DataAccessException

Deprecated

as a consequence of Field being deprecated. See corresponding docs for further information.

Find a unique record by a given field and a value.

Parameters
field:Field<Z>

The field to compare value against

value:Z

The accepted value

Returns:P

A record fulfilling field = value, or null

Annotations
@Nullable
@Support
Exceptions
DataAccessException:
This exception is thrown
  • if something went wrong executing the query
  • if the query returned more than one value
fetchOptionalback to summary
public <Z> @NotNull Optional<@NotNull P> fetchOptional(Field<Z> field, Z value) throws DataAccessException

Deprecated

as a consequence of Field being deprecated. See corresponding docs for further information.

Find a unique record by a given field and a value.

Parameters
field:Field<Z>

The field to compare value against

value:Z

The accepted value

Returns:@NotNull Optional<@NotNull P>

A record fulfilling field = value

Annotations
@NotNull
@Support
Exceptions
DataAccessException:
This exception is thrown
  • if something went wrong executing the query
  • if the query returned more than one value
fetchRangeback to summary
public <Z> @NotNull List<P> fetchRange(Field<Z> field, Z lowerInclusive, Z upperInclusive) throws DataAccessException

Deprecated

as a consequence of Field being deprecated. See corresponding docs for further information.

Find records by a given field and a range of values.

Parameters
field:Field<Z>

The field to compare values against

lowerInclusive:Z

The range's lower bound (inclusive), or unbounded if null.

upperInclusive:Z

The range's upper bound (inclusive), or unbounded if null.

Returns:@NotNull List<P>

A list of records fulfilling field BETWEEN lowerInclusive AND upperInclusive

Annotations
@NotNull
@Support
Exceptions
DataAccessException:
if something went wrong executing the query
findAllback to summary
public @NotNull List<@NotNull P> findAll() throws DataAccessException

Find all records of the underlying table.

Returns:@NotNull List<@NotNull P>

All records of the underlying table

Annotations
@NotNull
@Support
Exceptions
DataAccessException:
if something went wrong executing the query
findByIdback to summary
public P findById(T id) throws DataAccessException

Find a record of the underlying table by ID.

Parameters
id:T

The ID of a record in the underlying table

Returns:P

A record of the underlying table given its ID, or null if no record was found.

Annotations
@Nullable
@Support
Exceptions
DataAccessException:
if something went wrong executing the query
findOptionalByIdback to summary
public @NotNull Optional<@NotNull P> findOptionalById(T id) throws DataAccessException

Find a record of the underlying table by ID.

Parameters
id:T

The ID of a record in the underlying table

Returns:@NotNull Optional<@NotNull P>

A record of the underlying table given its ID.

Annotations
@NotNull
@Support
Exceptions
DataAccessException:
if something went wrong executing the query
getIdback to summary
public T getId(P object)

Extract the ID value from a POJO.

getTableback to summary
public @NotNull Table<R> getTable()

Get the underlying table.

Annotations
@NotNull
getTypeback to summary
public @NotNull Class<P> getType()

Get the underlying POJO type.

Annotations
@NotNull
insertback to summary
public void insert(P object) throws DataAccessException

Performs an INSERT statement for a given POJO.

Depending on various settings, like Settings#isReturnRecordToPojo(), Settings#isReturnIdentityOnUpdatableRecord(), Settings#isReturnAllOnUpdatableRecord(), and others, the argument POJO, if mutable, will receive any server side generated values using a Record#into(Object) call.

Parameters
object:P

The POJO to be inserted

Annotations
@Support
Exceptions
DataAccessException:
if something went wrong executing the query
insertback to summary
public void insert(P... objects) throws DataAccessException

Performs a batch INSERT statement for a given set of POJOs.

Depending on various settings, like Settings#isReturnRecordToPojo(), Settings#isReturnIdentityOnUpdatableRecord(), Settings#isReturnAllOnUpdatableRecord(), and others, the argument POJO, if mutable, will receive any server side generated values using a Record#into(Object) call.

Parameters
objects:P[]

The POJOs to be inserted

Annotations
@Support
Exceptions
DataAccessException:
if something went wrong executing the query
See Also
insert(Collection)
insertback to summary
public void insert(Collection<P> objects) throws DataAccessException

Performs a batch INSERT statement for a given set of POJOs.

Depending on various settings, like Settings#isReturnRecordToPojo(), Settings#isReturnIdentityOnUpdatableRecord(), Settings#isReturnAllOnUpdatableRecord(), and others, the argument POJO, if mutable, will receive any server side generated values using a Record#into(Object) call.

Parameters
objects:Collection<P>

The POJOs to be inserted

Annotations
@Support
Exceptions
DataAccessException:
if something went wrong executing the query
See Also
insert(Object...)
mapperback to summary
public @NotNull RecordMapper<R, P> mapper()

Expose the RecordMapper that is used internally by this DAO to map from records of type R to POJOs of type P.

Returns:@NotNull RecordMapper<R, P>

the DAO's underlying RecordMapper

Annotations
@NotNull
mergeback to summary
public void merge(P object) throws DataAccessException

Performs an MERGE statement for a given POJO.

Parameters
object:P

The POJO to be merged

Annotations
@Support:CUBRID, DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE
Exceptions
DataAccessException:
if something went wrong executing the query
mergeback to summary
public void merge(P... objects) throws DataAccessException

Performs a batch MERGE statement for a given set of POJOs.

Parameters
objects:P[]

The POJOs to be merged

Annotations
@Support:CUBRID, DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE
Exceptions
DataAccessException:
if something went wrong executing the query
See Also
update(Collection)
mergeback to summary
public void merge(Collection<P> objects) throws DataAccessException

Performs a batch MERGE statement for a given set of POJOs.

Parameters
objects:Collection<P>

The POJOs to be merged

Annotations
@Support:CUBRID, DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE
Exceptions
DataAccessException:
if something went wrong executing the query
See Also
update(Object...)
settingsback to summary
public @NotNull Settings settings()

The settings wrapped by this context.

This method is a convenient way of accessing configuration().settings().

Annotations
@NotNull
updateback to summary
public void update(P object) throws DataAccessException

Performs an UPDATE statement for a given POJO.

Depending on various settings, like Settings#isReturnRecordToPojo(), Settings#isReturnIdentityOnUpdatableRecord(), Settings#isReturnAllOnUpdatableRecord(), and others, the argument POJO, if mutable, will receive any server side generated values using a Record#into(Object) call, if UPDATE … RETURNING is supported by the dialect.

Parameters
object:P

The POJO to be updated

Annotations
@Support
Exceptions
DataAccessException:
if something went wrong executing the query
updateback to summary
public void update(P... objects) throws DataAccessException

Performs a batch UPDATE statement for a given set of POJOs.

Depending on various settings, like Settings#isReturnRecordToPojo(), Settings#isReturnIdentityOnUpdatableRecord(), Settings#isReturnAllOnUpdatableRecord(), and others, the argument POJO, if mutable, will receive any server side generated values using a Record#into(Object) call, if UPDATE … RETURNING is supported by the dialect.

Parameters
objects:P[]

The POJOs to be updated

Annotations
@Support
Exceptions
DataAccessException:
if something went wrong executing the query
See Also
update(Collection)
updateback to summary
public void update(Collection<P> objects) throws DataAccessException

Performs a batch UPDATE statement for a given set of POJOs.

Depending on various settings, like Settings#isReturnRecordToPojo(), Settings#isReturnIdentityOnUpdatableRecord(), Settings#isReturnAllOnUpdatableRecord(), and others, the argument POJO, if mutable, will receive any server side generated values using a Record#into(Object) call, if UPDATE … RETURNING is supported by the dialect.

Parameters
objects:Collection<P>

The POJOs to be updated

Annotations
@Support
Exceptions
DataAccessException:
if something went wrong executing the query
See Also
update(Object...)