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.
|
DSLContext |
ctx() |
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 |
delete(P object)
Performs a
DELETE statement for a POJO |
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.
|
<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 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 |
merge(Collection<P> objects)
Performs a batch
MERGE statement for a given set of POJOs. |
void |
merge(P... objects)
Performs a batch
MERGE statement for a given set of POJOs. |
void |
merge(P object)
Performs an
MERGE statement for a given POJO. |
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 final DSLContext ctx()
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().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 POJO.public void insert(P... objects)
DAO
INSERT
statement for a given set of POJOs.insert
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 POJOs.insert
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 POJO.public void update(P... objects)
DAO
UPDATE
statement for a given set of POJOs.update
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 POJOs.update
in interface DAO<R extends UpdatableRecord<R>,P,T>
objects
- The POJOs to be updatedDAO.update(Object...)
public void merge(P object)
DAO
MERGE
statement for a given POJO.public void merge(P... objects)
DAO
MERGE
statement for a given set of POJOs.merge
in interface DAO<R extends UpdatableRecord<R>,P,T>
objects
- The POJOs to be mergedDAO.update(Collection)
public void merge(Collection<P> objects)
DAO
MERGE
statement for a given set of POJOs.merge
in interface DAO<R extends UpdatableRecord<R>,P,T>
objects
- The POJOs to be mergedDAO.update(Object...)
public void delete(P object)
DAO
DELETE
statement for a POJOdelete
in interface DAO<R extends UpdatableRecord<R>,P,T>
object
- The POJO to be deletedDAO.delete(Collection)
public void delete(P... objects)
DAO
DELETE
statement for a given set of POJOs.delete
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 POJOs.delete
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 IDs.deleteById
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 IDs.deleteById
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> fetchRange(Field<Z> field, Z lowerInclusive, Z upperInclusive)
DAO
fetchRange
in interface DAO<R extends UpdatableRecord<R>,P,T>
field
- The field to compare values againstlowerInclusive
- The range's lower bound (inclusive), or unbounded
if null
.upperInclusive
- The range's upper bound (inclusive), or unbounded
if null
.field BETWEEN lowerInclusive AND upperInclusive
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 Table<R> getTable()
DAO
public Class<P> getType()
DAO
Copyright © 2021. All rights reserved.