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()
DAO
DAO
is
operating.configuration
in interface DAO<R extends UpdatableRecord<R>,P,T>
DAO
's underlying Configuration
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 final void insert(P object)
DAO
INSERT
statement for a given POJOpublic final 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 final 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 final void update(P object)
DAO
UPDATE
statement for a given POJOpublic final 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 final 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 final 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 final 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 final 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 final 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 final boolean exists(P object)
DAO
public final boolean existsById(T id)
DAO
existsById
in interface DAO<R extends UpdatableRecord<R>,P,T>
id
- The ID whose existence is checkedpublic final long count()
DAO
public final List<P> findAll()
DAO
public final P findById(T id)
DAO
public final <Z> List<P> fetch(Field<Z> field, Z... values)
DAO
public final <Z> P fetchOne(Field<Z> field, Z value)
DAO
public final Table<R> getTable()
DAO
public final Class<P> getType()
DAO
Copyright © 2014. All Rights Reserved.