- 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,
DAOmay be used in the context of Spring, CDI, or EJB lifecycle management. This means that no methods in theDAOtype 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 TcompositeKeyRecord(Object... values)Configurationconfiguration()Expose the configuration in whose context thisDAOis operating.longcount()Count all records of the underlying table.DSLContextctx()voiddelete(Collection<P> objects)Performs aDELETEstatement for a given set of POJOs.voiddelete(P object)Performs aDELETEstatement for a POJOvoiddelete(P... objects)Performs aDELETEstatement for a given set of POJOs.voiddeleteById(Collection<T> ids)Performs aDELETEstatement for a given set of IDs.voiddeleteById(T... ids)Performs aDELETEstatement for a given set of IDs.SQLDialectdialect()TheSQLDialectwrapped by this context.booleanexists(P object)Checks if a given POJO exists.booleanexistsById(T id)Checks if a given ID exists.SQLDialectfamily()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> PfetchOne(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.PfindById(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.voidinsert(Collection<P> objects)Performs a batchINSERTstatement for a given set of POJOs.voidinsert(P object)Performs anINSERTstatement for a given POJO.voidinsert(P... objects)Performs a batchINSERTstatement for a given set of POJOs.RecordMapper<R,P>mapper()Expose theRecordMapperthat is used internally by thisDAOto map from records of typeRto POJOs of typeP.voidmerge(Collection<P> objects)Performs a batchMERGEstatement for a given set of POJOs.voidmerge(P object)Performs anMERGEstatement for a given POJO.voidmerge(P... objects)Performs a batchMERGEstatement for a given set of POJOs.voidsetConfiguration(Configuration configuration)Inject a configuration.Settingssettings()The settings wrapped by this context.voidupdate(Collection<P> objects)Performs a batchUPDATEstatement for a given set of POJOs.voidupdate(P object)Performs anUPDATEstatement for a given POJO.voidupdate(P... objects)Performs a batchUPDATEstatement 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
DAOusing Spring. It is not exposed in the public API.
-
ctx
public final DSLContext ctx()
-
configuration
public Configuration configuration()
Description copied from interface:DAOExpose the configuration in whose context thisDAOis operating.- Specified by:
configurationin interfaceDAO<R extends UpdatableRecord<R>,P,T>- Returns:
- the
DAO's underlyingConfiguration
-
settings
public Settings settings()
Description copied from interface:DAOThe settings wrapped by this context.This method is a convenient way of accessing
configuration().settings().
-
dialect
public SQLDialect dialect()
Description copied from interface:DAOTheSQLDialectwrapped by this context.This method is a convenient way of accessing
configuration().dialect().
-
family
public SQLDialect family()
Description copied from interface:DAOTheSQLDialect.family()wrapped by this context.This method is a convenient way of accessing
configuration().family().
-
mapper
public RecordMapper<R,P> mapper()
Expose theRecordMapperthat is used internally by thisDAOto map from records of typeRto POJOs of typeP.Subclasses may override this method to provide custom implementations.
-
insert
public void insert(P object)
Description copied from interface:DAOPerforms anINSERTstatement for a given POJO.
-
insert
public void insert(P... objects)
Description copied from interface:DAOPerforms a batchINSERTstatement for a given set of POJOs.- Specified by:
insertin 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:DAOPerforms a batchINSERTstatement for a given set of POJOs.- Specified by:
insertin 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:DAOPerforms anUPDATEstatement for a given POJO.
-
update
public void update(P... objects)
Description copied from interface:DAOPerforms a batchUPDATEstatement for a given set of POJOs.- Specified by:
updatein 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:DAOPerforms a batchUPDATEstatement for a given set of POJOs.- Specified by:
updatein 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:DAOPerforms anMERGEstatement for a given POJO.
-
merge
public void merge(P... objects)
Description copied from interface:DAOPerforms a batchMERGEstatement for a given set of POJOs.- Specified by:
mergein 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:DAOPerforms a batchMERGEstatement for a given set of POJOs.- Specified by:
mergein 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:DAOPerforms aDELETEstatement for a POJO- Specified by:
deletein 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:DAOPerforms aDELETEstatement for a given set of POJOs.- Specified by:
deletein 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:DAOPerforms aDELETEstatement for a given set of POJOs.- Specified by:
deletein 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:DAOPerforms aDELETEstatement for a given set of IDs.- Specified by:
deleteByIdin 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:DAOPerforms aDELETEstatement for a given set of IDs.- Specified by:
deleteByIdin 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:DAOChecks if a given POJO exists.
-
existsById
public boolean existsById(T id)
Description copied from interface:DAOChecks if a given ID exists.- Specified by:
existsByIdin 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:DAOCount all records of the underlying table.
-
findAll
public List<P> findAll()
Description copied from interface:DAOFind all records of the underlying table.
-
findById
public P findById(T id)
Description copied from interface:DAOFind 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:DAOFind records by a given field and a range of values.- Specified by:
fetchRangein 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:DAOFind records by a given field and a set of values.
-
fetchOne
public <Z> P fetchOne(Field<Z> field, Z value)
Description copied from interface:DAOFind 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:DAOFind a unique record by a given field and a value.- Specified by:
fetchOptionalin 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:DAOGet the underlying table.
-
getType
public Class<P> getType()
Description copied from interface:DAOGet the underlying POJO type.
-
-