public abstract class DAOImpl<R extends UpdatableRecord<R>,P,T> extends Object implements DAO<R,P,T>
DAO
.
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 the DAO
type hierarchy must be made final. See also
https://github.com/jOOQ/
jOOQ/issues/4696 for more details.
Modifier | Constructor and Description |
---|---|
protected |
DAOImpl(Table<R> table,
Class<P> type) |
protected |
DAOImpl(Table<R> table,
Class<P> type,
Configuration configuration) |
Modifier and Type | Method and Description |
---|---|
protected T |
compositeKeyRecord(Object... values) |
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.
|
protected abstract T |
getId(P object) |
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 . |
void |
setConfiguration(Configuration configuration)
Inject a configuration.
|
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 |
protected DAOImpl(Table<R> table, Class<P> type, Configuration configuration)
public void setConfiguration(Configuration configuration)
This method is maintained to be able to configure a DAO
using Spring. It is not exposed in the public API.
public Configuration configuration()
DAO
DAO
is
operating.configuration
in interface DAO<R extends UpdatableRecord<R>,P,T>
DAO
's underlying Configuration
public Settings settings()
DAO
This method is a convenient way of accessing
configuration().settings()
.
public SQLDialect dialect()
DAO
SQLDialect
wrapped by this context.
This method is a convenient way of accessing
configuration().dialect()
.
public SQLDialect family()
DAO
SQLDialect.family()
wrapped by this context.
This method is a convenient way of accessing
configuration().dialect().family()
.
public RecordMapper<R,P> mapper()
RecordMapper
that is used internally by this
DAO
to map from records of type R
to POJOs of
type P
.
Subclasses may override this method to provide custom implementations.
public void insert(P object)
DAO
INSERT
statement for a given POJOpublic void insert(P... objects)
DAO
INSERT
statement for a given set of POJOsinsert
in interface DAO<R extends UpdatableRecord<R>,P,T>
objects
- The POJOs to be insertedDAO.insert(Collection)
public void insert(Collection<P> objects)
DAO
INSERT
statement for a given set of POJOsinsert
in interface DAO<R extends UpdatableRecord<R>,P,T>
objects
- The POJOs to be insertedDAO.insert(Object...)
public void update(P object)
DAO
UPDATE
statement for a given POJOpublic void update(P... objects)
DAO
UPDATE
statement for a given set of POJOsupdate
in interface DAO<R extends UpdatableRecord<R>,P,T>
objects
- The POJOs to be updatedDAO.update(Collection)
public void update(Collection<P> objects)
DAO
UPDATE
statement for a given set of POJOsupdate
in interface DAO<R extends UpdatableRecord<R>,P,T>
objects
- The POJOs to be updatedDAO.update(Object...)
public void delete(P... objects)
DAO
DELETE
statement for a given set of POJOsdelete
in interface DAO<R extends UpdatableRecord<R>,P,T>
objects
- The POJOs to be deletedDAO.delete(Collection)
public void delete(Collection<P> objects)
DAO
DELETE
statement for a given set of POJOsdelete
in interface DAO<R extends UpdatableRecord<R>,P,T>
objects
- The POJOs to be deletedDAO.delete(Object...)
public void deleteById(T... ids)
DAO
DELETE
statement for a given set of IDsdeleteById
in interface DAO<R extends UpdatableRecord<R>,P,T>
ids
- The IDs to be deletedDAO.delete(Collection)
public void deleteById(Collection<T> ids)
DAO
DELETE
statement for a given set of IDsdeleteById
in interface DAO<R extends UpdatableRecord<R>,P,T>
ids
- The IDs to be deletedDAO.delete(Object...)
public boolean exists(P object)
DAO
public boolean existsById(T id)
DAO
existsById
in interface DAO<R extends UpdatableRecord<R>,P,T>
id
- The ID whose existence is checkedpublic long count()
DAO
public List<P> findAll()
DAO
public P findById(T id)
DAO
public <Z> List<P> fetch(Field<Z> field, Z... values)
DAO
public <Z> P fetchOne(Field<Z> field, Z value)
DAO
public <Z> Optional<P> fetchOptional(Field<Z> field, Z value)
DAO
fetchOptional
in interface DAO<R extends UpdatableRecord<R>,P,T>
field
- The field to compare value againstvalue
- The accepted valuefield = value
public Class<P> getType()
DAO
Copyright © 2016. All Rights Reserved.