- java.lang.Object
-
- org.jooq.impl.DAOImpl<R,P,T>
-
- All Implemented Interfaces:
DAO<R,P,T>
public abstract class DAOImpl<R extends UpdatableRecord<R>,P,T> extends Object implements DAO<R,P,T>
A common base implementation for generatedDAO
.Unlike many other elements in the jOOQ API,
DAO
may be used in the context of Spring, CDI, or EJB lifecycle management. This means that no methods in theDAO
type hierarchy must be made final. See also https://github.com/jOOQ/ jOOQ/issues/4696 for more details.- Author:
- Lukas Eder
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected T
compositeKeyRecord(Object... values)
Configuration
configuration()
Expose the configuration in whose context thisDAO
is operating.long
count()
Count all records of the underlying table.DSLContext
ctx()
void
delete(Collection<P> objects)
Performs aDELETE
statement for a given set of POJOs.void
delete(P object)
Performs aDELETE
statement for a POJOvoid
delete(P... objects)
Performs aDELETE
statement for a given set of POJOs.void
deleteById(Collection<T> ids)
Performs aDELETE
statement for a given set of IDs.void
deleteById(T... ids)
Performs aDELETE
statement for a given set of IDs.SQLDialect
dialect()
TheSQLDialect
wrapped by this context.boolean
exists(P object)
Checks if a given POJO exists.boolean
existsById(T id)
Checks if a given ID exists.SQLDialect
family()
TheSQLDialect.family()
wrapped by this context.<Z> List<P>
fetch(Field<Z> field, Z... values)
Find records by a given field and a set of values.<Z> P
fetchOne(Field<Z> field, Z value)
Find a unique record by a given field and a value.<Z> Optional<P>
fetchOptional(Field<Z> field, Z value)
Find a unique record by a given field and a value.<Z> List<P>
fetchRange(Field<Z> field, Z lowerInclusive, Z upperInclusive)
Find records by a given field and a range of values.List<P>
findAll()
Find all records of the underlying table.P
findById(T id)
Find a record of the underlying table by ID.Table<R>
getTable()
Get the underlying table.Class<P>
getType()
Get the underlying POJO type.void
insert(Collection<P> objects)
Performs a batchINSERT
statement for a given set of POJOs.void
insert(P object)
Performs anINSERT
statement for a given POJO.void
insert(P... objects)
Performs a batchINSERT
statement for a given set of POJOs.RecordMapper<R,P>
mapper()
Expose theRecordMapper
that is used internally by thisDAO
to map from records of typeR
to POJOs of typeP
.void
merge(Collection<P> objects)
Performs a batchMERGE
statement for a given set of POJOs.void
merge(P object)
Performs anMERGE
statement for a given POJO.void
merge(P... objects)
Performs a batchMERGE
statement for a given set of POJOs.void
setConfiguration(Configuration configuration)
Inject a configuration.Settings
settings()
The settings wrapped by this context.void
update(Collection<P> objects)
Performs a batchUPDATE
statement for a given set of POJOs.void
update(P object)
Performs anUPDATE
statement for a given POJO.void
update(P... objects)
Performs a batchUPDATE
statement for a given set of POJOs.
-
-
-
Method Detail
-
setConfiguration
public void setConfiguration(Configuration configuration)
Inject a configuration.This method is maintained to be able to configure a
DAO
using Spring. It is not exposed in the public API.
-
ctx
public final DSLContext ctx()
-
configuration
public Configuration configuration()
Description copied from interface:DAO
Expose the configuration in whose context thisDAO
is operating.- Specified by:
configuration
in interfaceDAO<R extends UpdatableRecord<R>,P,T>
- Returns:
- the
DAO
's underlyingConfiguration
-
settings
public Settings settings()
Description copied from interface:DAO
The settings wrapped by this context.This method is a convenient way of accessing
configuration().settings()
.
-
dialect
public SQLDialect dialect()
Description copied from interface:DAO
TheSQLDialect
wrapped by this context.This method is a convenient way of accessing
configuration().dialect()
.
-
family
public SQLDialect family()
Description copied from interface:DAO
TheSQLDialect.family()
wrapped by this context.This method is a convenient way of accessing
configuration().family()
.
-
mapper
public RecordMapper<R,P> mapper()
Expose theRecordMapper
that is used internally by thisDAO
to map from records of typeR
to POJOs of typeP
.Subclasses may override this method to provide custom implementations.
-
insert
public void insert(P object)
Description copied from interface:DAO
Performs anINSERT
statement for a given POJO.
-
insert
public void insert(P... objects)
Description copied from interface:DAO
Performs a batchINSERT
statement for a given set of POJOs.- Specified by:
insert
in interfaceDAO<R extends UpdatableRecord<R>,P,T>
- Parameters:
objects
- The POJOs to be inserted- See Also:
DAO.insert(Collection)
-
insert
public void insert(Collection<P> objects)
Description copied from interface:DAO
Performs a batchINSERT
statement for a given set of POJOs.- Specified by:
insert
in interfaceDAO<R extends UpdatableRecord<R>,P,T>
- Parameters:
objects
- The POJOs to be inserted- See Also:
DAO.insert(Object...)
-
update
public void update(P object)
Description copied from interface:DAO
Performs anUPDATE
statement for a given POJO.
-
update
public void update(P... objects)
Description copied from interface:DAO
Performs a batchUPDATE
statement for a given set of POJOs.- Specified by:
update
in interfaceDAO<R extends UpdatableRecord<R>,P,T>
- Parameters:
objects
- The POJOs to be updated- See Also:
DAO.update(Collection)
-
update
public void update(Collection<P> objects)
Description copied from interface:DAO
Performs a batchUPDATE
statement for a given set of POJOs.- Specified by:
update
in interfaceDAO<R extends UpdatableRecord<R>,P,T>
- Parameters:
objects
- The POJOs to be updated- See Also:
DAO.update(Object...)
-
merge
public void merge(P object)
Description copied from interface:DAO
Performs anMERGE
statement for a given POJO.
-
merge
public void merge(P... objects)
Description copied from interface:DAO
Performs a batchMERGE
statement for a given set of POJOs.- Specified by:
merge
in interfaceDAO<R extends UpdatableRecord<R>,P,T>
- Parameters:
objects
- The POJOs to be merged- See Also:
DAO.update(Collection)
-
merge
public void merge(Collection<P> objects)
Description copied from interface:DAO
Performs a batchMERGE
statement for a given set of POJOs.- Specified by:
merge
in interfaceDAO<R extends UpdatableRecord<R>,P,T>
- Parameters:
objects
- The POJOs to be merged- See Also:
DAO.update(Object...)
-
delete
public void delete(P object)
Description copied from interface:DAO
Performs aDELETE
statement for a POJO- Specified by:
delete
in interfaceDAO<R extends UpdatableRecord<R>,P,T>
- Parameters:
object
- The POJO to be deleted- See Also:
DAO.delete(Collection)
-
delete
public void delete(P... objects)
Description copied from interface:DAO
Performs aDELETE
statement for a given set of POJOs.- Specified by:
delete
in interfaceDAO<R extends UpdatableRecord<R>,P,T>
- Parameters:
objects
- The POJOs to be deleted- See Also:
DAO.delete(Collection)
-
delete
public void delete(Collection<P> objects)
Description copied from interface:DAO
Performs aDELETE
statement for a given set of POJOs.- Specified by:
delete
in interfaceDAO<R extends UpdatableRecord<R>,P,T>
- Parameters:
objects
- The POJOs to be deleted- See Also:
DAO.delete(Object...)
-
deleteById
public void deleteById(T... ids)
Description copied from interface:DAO
Performs aDELETE
statement for a given set of IDs.- Specified by:
deleteById
in interfaceDAO<R extends UpdatableRecord<R>,P,T>
- Parameters:
ids
- The IDs to be deleted- See Also:
DAO.delete(Collection)
-
deleteById
public void deleteById(Collection<T> ids)
Description copied from interface:DAO
Performs aDELETE
statement for a given set of IDs.- Specified by:
deleteById
in interfaceDAO<R extends UpdatableRecord<R>,P,T>
- Parameters:
ids
- The IDs to be deleted- See Also:
DAO.delete(Object...)
-
exists
public boolean exists(P object)
Description copied from interface:DAO
Checks if a given POJO exists.
-
existsById
public boolean existsById(T id)
Description copied from interface:DAO
Checks if a given ID exists.- Specified by:
existsById
in interfaceDAO<R extends UpdatableRecord<R>,P,T>
- Parameters:
id
- The ID whose existence is checked- Returns:
- Whether the ID already exists
-
count
public long count()
Description copied from interface:DAO
Count all records of the underlying table.
-
findAll
public List<P> findAll()
Description copied from interface:DAO
Find all records of the underlying table.
-
findById
public P findById(T id)
Description copied from interface:DAO
Find a record of the underlying table by ID.
-
fetchRange
public <Z> List<P> fetchRange(Field<Z> field, Z lowerInclusive, Z upperInclusive)
Description copied from interface:DAO
Find records by a given field and a range of values.- Specified by:
fetchRange
in interfaceDAO<R extends UpdatableRecord<R>,P,T>
- Parameters:
field
- The field to compare values againstlowerInclusive
- The range's lower bound (inclusive), or unbounded ifnull
.upperInclusive
- The range's upper bound (inclusive), or unbounded ifnull
.- Returns:
- A list of records fulfilling
field BETWEEN lowerInclusive AND upperInclusive
-
fetch
public <Z> List<P> fetch(Field<Z> field, Z... values)
Description copied from interface:DAO
Find records by a given field and a set of values.
-
fetchOne
public <Z> P fetchOne(Field<Z> field, Z value)
Description copied from interface:DAO
Find a unique record by a given field and a value.
-
fetchOptional
public <Z> Optional<P> fetchOptional(Field<Z> field, Z value)
Description copied from interface:DAO
Find a unique record by a given field and a value.- Specified by:
fetchOptional
in interfaceDAO<R extends UpdatableRecord<R>,P,T>
- Parameters:
field
- The field to compare value againstvalue
- The accepted value- Returns:
- A record fulfilling
field = value
-
getTable
public Table<R> getTable()
Description copied from interface:DAO
Get the underlying table.
-
getType
public Class<P> getType()
Description copied from interface:DAO
Get the underlying POJO type.
-
-