public abstract class DAOImpl<R extends UpdatableRecord<R>,P,T> extends Object implements DAO<R,P,T>
| 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 |
|---|---|
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 |
boolean |
exists(P object)
Checks if a given POJO exists
|
boolean |
existsById(T id)
Checks if a given ID exists
|
<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.
|
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.
|
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 final 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 Configuration configuration()
DAODAO is
operating.configuration in interface DAO<R extends UpdatableRecord<R>,P,T>DAO's underlying Configurationpublic 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 final void insert(P object)
DAOINSERT statement for a given POJOpublic final void insert(P... objects)
DAOINSERT 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 final void insert(Collection<P> objects)
DAOINSERT 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 final void update(P object)
DAOUPDATE statement for a given POJOpublic final void update(P... objects)
DAOUPDATE 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 final void update(Collection<P> objects)
DAOUPDATE 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 final void delete(P... objects)
DAODELETE 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 final void delete(Collection<P> objects)
DAODELETE 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 final void deleteById(T... ids)
DAODELETE 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 final void deleteById(Collection<T> ids)
DAODELETE 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 final boolean exists(P object)
DAOpublic final boolean existsById(T id)
DAOexistsById in interface DAO<R extends UpdatableRecord<R>,P,T>id - The ID whose existence is checkedpublic final long count()
DAOpublic final List<P> findAll()
DAOpublic final P findById(T id)
DAOpublic final <Z> List<P> fetch(Field<Z> field, Z... values)
DAOpublic final <Z> P fetchOne(Field<Z> field, Z value)
DAOpublic final Table<R> getTable()
DAOpublic final Class<P> getType()
DAOCopyright © 2014. All Rights Reserved.