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.public interface DAO<R extends TableRecord<R>,P,T>
This type is implemented by generated DAO classes to provide a common API for common actions on POJOs
Modifier and Type | Method and Description |
---|---|
Configuration |
configuration()
Expose the configuration in whose context this
DAO is
operating. |
long |
count()
Count all records of the underlying table.
|
void |
delete(Collection<P> objects)
Performs a
DELETE statement for a given set of POJOs |
void |
delete(P... objects)
Performs a
DELETE statement for a given set of POJOs |
void |
deleteById(Collection<T> ids)
Performs a
DELETE statement for a given set of IDs |
void |
deleteById(T... ids)
Performs a
DELETE statement for a given set of IDs |
SQLDialect |
dialect()
The
SQLDialect 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()
The
SQLDialect.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.
|
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 batch
INSERT statement for a given set of POJOs |
void |
insert(P... objects)
Performs a batch
INSERT statement for a given set of POJOs |
void |
insert(P object)
Performs an
INSERT statement for a given POJO |
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 . |
Settings |
settings()
The settings wrapped by this context.
|
void |
update(Collection<P> objects)
Performs a batch
UPDATE statement for a given set of POJOs |
void |
update(P... objects)
Performs a batch
UPDATE statement for a given set of POJOs |
void |
update(P object)
Performs an
UPDATE statement for a given POJO |
Configuration configuration()
DAO
is
operating.DAO
's underlying Configuration
Settings settings()
This method is a convenient way of accessing
configuration().settings()
.
SQLDialect dialect()
SQLDialect
wrapped by this context.
This method is a convenient way of accessing
configuration().dialect()
.
SQLDialect family()
SQLDialect.family()
wrapped by this context.
This method is a convenient way of accessing
configuration().dialect().family()
.
RecordMapper<R,P> mapper()
RecordMapper
that is used internally by this
DAO
to map from records of type R
to POJOs of
type P
.DAO
's underlying RecordMapper
void insert(P object) throws DataAccessException
INSERT
statement for a given POJOobject
- The POJO to be insertedDataAccessException
- if something went wrong executing the queryvoid insert(P... objects) throws DataAccessException
INSERT
statement for a given set of POJOsobjects
- The POJOs to be insertedDataAccessException
- if something went wrong executing the queryinsert(Collection)
void insert(Collection<P> objects) throws DataAccessException
INSERT
statement for a given set of POJOsobjects
- The POJOs to be insertedDataAccessException
- if something went wrong executing the queryinsert(Object...)
void update(P object) throws DataAccessException
UPDATE
statement for a given POJOobject
- The POJO to be updatedDataAccessException
- if something went wrong executing the queryvoid update(P... objects) throws DataAccessException
UPDATE
statement for a given set of POJOsobjects
- The POJOs to be updatedDataAccessException
- if something went wrong executing the queryupdate(Collection)
void update(Collection<P> objects) throws DataAccessException
UPDATE
statement for a given set of POJOsobjects
- The POJOs to be updatedDataAccessException
- if something went wrong executing the queryupdate(Object...)
void delete(P... objects) throws DataAccessException
DELETE
statement for a given set of POJOsobjects
- The POJOs to be deletedDataAccessException
- if something went wrong executing the querydelete(Collection)
void delete(Collection<P> objects) throws DataAccessException
DELETE
statement for a given set of POJOsobjects
- The POJOs to be deletedDataAccessException
- if something went wrong executing the querydelete(Object...)
void deleteById(T... ids) throws DataAccessException
DELETE
statement for a given set of IDsids
- The IDs to be deletedDataAccessException
- if something went wrong executing the querydelete(Collection)
void deleteById(Collection<T> ids) throws DataAccessException
DELETE
statement for a given set of IDsids
- The IDs to be deletedDataAccessException
- if something went wrong executing the querydelete(Object...)
boolean exists(P object) throws DataAccessException
object
- The POJO whose existence is checkedDataAccessException
- if something went wrong executing the queryboolean existsById(T id) throws DataAccessException
id
- The ID whose existence is checkedDataAccessException
- if something went wrong executing the querylong count() throws DataAccessException
DataAccessException
- if something went wrong executing the queryList<P> findAll() throws DataAccessException
DataAccessException
- if something went wrong executing the queryP findById(T id) throws DataAccessException
id
- The ID of a record in the underlying tablenull
if no record was found.DataAccessException
- if something went wrong executing the query<Z> List<P> fetch(Field<Z> field, Z... values) throws DataAccessException
field
- The field to compare values againstvalues
- The accepted valuesfield IN (values)
DataAccessException
- if something went wrong executing the query<Z> P fetchOne(Field<Z> field, Z value) throws DataAccessException
field
- The field to compare value againstvalue
- The accepted valuefield = value
, or
null
DataAccessException
- This exception is thrown
<Z> Optional<P> fetchOptional(Field<Z> field, Z value) throws DataAccessException
field
- The field to compare value againstvalue
- The accepted valuefield = value
DataAccessException
- This exception is thrown
Copyright © 2016. All Rights Reserved.