- 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- Recordsubtype for composite keys.
- All Known Implementing Classes:
- DAOImpl
This type is implemented by generated DAO classes to provide a common API for common actions on POJOs
- Author:
- Lukas Eder
- 
Method SummaryModifier and TypeMethodDescription@NotNull ConfigurationExpose the configuration in whose context thisDAOis operating.longcount()Count all records of the underlying table.voiddelete(Collection<P> objects) Performs aDELETEstatement for a given set of POJOs.voidPerforms aDELETEstatement for a POJOvoidPerforms aDELETEstatement for a given set of POJOs.voiddeleteById(Collection<T> ids) Performs aDELETEstatement for a given set of IDs.voiddeleteById(T id) Performs aDELETEstatement for a given set of IDs.voiddeleteById(T... ids) Performs aDELETEstatement for a given set of IDs.@NotNull SQLDialectdialect()TheSQLDialectwrapped by this context.booleanChecks if a given POJO exists.booleanexistsById(T id) Checks if a given ID exists.@NotNull SQLDialectfamily()TheSQLDialect.family()wrapped by this context.fetch(Field<Z> field, Collection<? extends Z> values) Find records by a given field and a set of values.Find records by a given field and a set of values.<Z> PFind a unique record by a given field and a value.fetchOptional(Field<Z> field, Z value) Find a unique record by a given field and a value.fetchRange(Field<Z> field, Z lowerInclusive, Z upperInclusive) Find records by a given field and a range of values.findAll()Find all records of the underlying table.Find a record of the underlying table by ID.findOptionalById(T id) Find a record of the underlying table by ID.Extract the ID value from a POJO.getTable()Get the underlying table.getType()Get the underlying POJO type.voidinsert(Collection<P> objects) Performs a batchINSERTstatement for a given set of POJOs.voidPerforms anINSERTstatement for a given POJO.voidPerforms a batchINSERTstatement for a given set of POJOs.@NotNull 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.voidPerforms anMERGEstatement for a given POJO.voidPerforms a batchMERGEstatement for a given set of POJOs.@NotNull Settingssettings()The settings wrapped by this context.voidupdate(Collection<P> objects) Performs a batchUPDATEstatement for a given set of POJOs.voidPerforms anUPDATEstatement for a given POJO.voidPerforms a batchUPDATEstatement for a given set of POJOs.
- 
Method Details- 
configurationExpose the configuration in whose context thisDAOis operating.- Returns:
- the DAO's underlyingConfiguration
 
- 
settingsThe settings wrapped by this context.This method is a convenient way of accessing configuration().settings().
- 
dialectTheSQLDialectwrapped by this context.This method is a convenient way of accessing configuration().dialect().
- 
familyTheSQLDialect.family()wrapped by this context.This method is a convenient way of accessing configuration().family().
- 
mapperExpose theRecordMapperthat is used internally by thisDAOto map from records of typeRto POJOs of typeP.- Returns:
- the DAO's underlyingRecordMapper
 
- 
insertPerforms anINSERTstatement 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 aRecord.into(Object)call.- Parameters:
- object- The POJO to be inserted
- Throws:
- DataAccessException- if something went wrong executing the query
 
- 
insertPerforms a batchINSERTstatement 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 aRecord.into(Object)call.- Parameters:
- objects- The POJOs to be inserted
- Throws:
- DataAccessException- if something went wrong executing the query
- See Also:
 
- 
insertPerforms a batchINSERTstatement 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 aRecord.into(Object)call.- Parameters:
- objects- The POJOs to be inserted
- Throws:
- DataAccessException- if something went wrong executing the query
- See Also:
 
- 
updatePerforms anUPDATEstatement 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 aRecord.into(Object)call, ifUPDATE … RETURNINGis supported by the dialect.- Parameters:
- object- The POJO to be updated
- Throws:
- DataAccessException- if something went wrong executing the query
 
- 
updatePerforms a batchUPDATEstatement 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 aRecord.into(Object)call, ifUPDATE … RETURNINGis supported by the dialect.- Parameters:
- objects- The POJOs to be updated
- Throws:
- DataAccessException- if something went wrong executing the query
- See Also:
 
- 
updatePerforms a batchUPDATEstatement 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 aRecord.into(Object)call, ifUPDATE … RETURNINGis supported by the dialect.- Parameters:
- objects- The POJOs to be updated
- Throws:
- DataAccessException- if something went wrong executing the query
- See Also:
 
- 
merge@Support({AURORA_MYSQL,AURORA_POSTGRES,COCKROACHDB,CUBRID,DB2,DERBY,H2,HSQLDB,INFORMIX,MARIADB,MEMSQL,MYSQL,ORACLE,POSTGRES_9_5,SQLITE,SQLSERVER,SYBASE,TERADATA}) void merge(P object) throws DataAccessException Performs anMERGEstatement for a given POJO.- Parameters:
- object- The POJO to be merged
- Throws:
- DataAccessException- if something went wrong executing the query
 
- 
merge@Support({AURORA_MYSQL,AURORA_POSTGRES,COCKROACHDB,CUBRID,DB2,DERBY,H2,HSQLDB,INFORMIX,MARIADB,MEMSQL,MYSQL,ORACLE,POSTGRES_9_5,SQLITE,SQLSERVER,SYBASE,TERADATA}) void merge(P... objects) throws DataAccessException Performs a batchMERGEstatement for a given set of POJOs.- Parameters:
- objects- The POJOs to be merged
- Throws:
- DataAccessException- if something went wrong executing the query
- See Also:
 
- 
merge@Support({AURORA_MYSQL,AURORA_POSTGRES,COCKROACHDB,CUBRID,DB2,DERBY,H2,HSQLDB,INFORMIX,MARIADB,MEMSQL,MYSQL,ORACLE,POSTGRES_9_5,SQLITE,SQLSERVER,SYBASE,TERADATA}) void merge(Collection<P> objects) throws DataAccessException Performs a batchMERGEstatement for a given set of POJOs.- Parameters:
- objects- The POJOs to be merged
- Throws:
- DataAccessException- if something went wrong executing the query
- See Also:
 
- 
deletePerforms aDELETEstatement for a POJO- Parameters:
- object- The POJO to be deleted
- Throws:
- DataAccessException- if something went wrong executing the query
- See Also:
 
- 
deletePerforms aDELETEstatement for a given set of POJOs.- Parameters:
- objects- The POJOs to be deleted
- Throws:
- DataAccessException- if something went wrong executing the query
- See Also:
 
- 
deletePerforms aDELETEstatement for a given set of POJOs.- Parameters:
- objects- The POJOs to be deleted
- Throws:
- DataAccessException- if something went wrong executing the query
- See Also:
 
- 
deleteByIdPerforms aDELETEstatement for a given set of IDs.- Parameters:
- ids- The IDs to be deleted
- Throws:
- DataAccessException- if something went wrong executing the query
- See Also:
 
- 
deleteByIdPerforms aDELETEstatement for a given set of IDs.- Parameters:
- ids- The IDs to be deleted
- Throws:
- DataAccessException- if something went wrong executing the query
- See Also:
 
- 
deleteByIdPerforms aDELETEstatement for a given set of IDs.- Parameters:
- ids- The IDs to be deleted
- Throws:
- DataAccessException- if something went wrong executing the query
- See Also:
 
- 
existsChecks if a given POJO exists.- Parameters:
- object- The POJO whose existence is checked
- Returns:
- Whether the POJO already exists
- Throws:
- DataAccessException- if something went wrong executing the query
 
- 
existsByIdChecks if a given ID exists.- Parameters:
- id- The ID whose existence is checked
- Returns:
- Whether the ID already exists
- Throws:
- DataAccessException- if something went wrong executing the query
 
- 
countCount all records of the underlying table.- Returns:
- The number of records of the underlying table
- Throws:
- DataAccessException- if something went wrong executing the query
 
- 
findAllFind all records of the underlying table.- Returns:
- All records of the underlying table
- Throws:
- DataAccessException- if something went wrong executing the query
 
- 
findByIdFind a record of the underlying table by ID.- Parameters:
- id- The ID of a record in the underlying table
- Returns:
- A record of the underlying table given its ID, or
         nullif no record was found.
- Throws:
- DataAccessException- if something went wrong executing the query
 
- 
findOptionalByIdFind a record of the underlying table by ID.- Parameters:
- id- The ID of a record in the underlying table
- Returns:
- A record of the underlying table given its ID.
- Throws:
- DataAccessException- if something went wrong executing the query
 
- 
fetch@NotNull @Support <Z> @NotNull List<P> fetch(Field<Z> field, Z... values) throws DataAccessException Find records by a given field and a set of values.- Parameters:
- field- The field to compare values against
- values- The accepted values
- Returns:
- A list of records fulfilling field IN (values)
- Throws:
- DataAccessException- if something went wrong executing the query
 
- 
fetch@NotNull @Support <Z> @NotNull List<P> fetch(Field<Z> field, Collection<? extends Z> values) throws DataAccessException Find records by a given field and a set of values.- Parameters:
- field- The field to compare values against
- values- The accepted values
- Returns:
- A list of records fulfilling field IN (values)
- Throws:
- DataAccessException- if something went wrong executing the query
 
- 
fetchRange@NotNull @Support <Z> @NotNull List<P> fetchRange(Field<Z> field, Z lowerInclusive, Z upperInclusive) throws DataAccessException Find records by a given field and a range of values.- Parameters:
- field- The field to compare values against
- lowerInclusive- The range's lower bound (inclusive), or unbounded if- null.
- upperInclusive- The range's upper bound (inclusive), or unbounded if- null.
- Returns:
- A list of records fulfilling
         field BETWEEN lowerInclusive AND upperInclusive
- Throws:
- DataAccessException- if something went wrong executing the query
 
- 
fetchOneFind a unique record by a given field and a value.- Parameters:
- field- The field to compare value against
- value- The accepted value
- Returns:
- A record fulfilling field = value, ornull
- Throws:
- DataAccessException- This exception is thrown- if something went wrong executing the query
- if the query returned more than one value
 
 
- 
fetchOptional@NotNull @Support <Z> @NotNull Optional<@NotNull P> fetchOptional(Field<Z> field, Z value) throws DataAccessException Find a unique record by a given field and a value.- Parameters:
- field- The field to compare value against
- value- The accepted value
- Returns:
- A record fulfilling field = value
- Throws:
- DataAccessException- This exception is thrown- if something went wrong executing the query
- if the query returned more than one value
 
 
- 
getTableGet the underlying table.
- 
getTypeGet the underlying POJO type.
- 
getIdExtract the ID value from a POJO.
 
-