public abstract class DAOImpl<R extends UpdatableRecord<R>,P,T> extends java.lang.Object implements DAO<R,P,T>
Modifier | Constructor and Description |
---|---|
protected |
DAOImpl(Table<R> table,
java.lang.Class<P> type) |
protected |
DAOImpl(Table<R> table,
java.lang.Class<P> type,
Configuration configuration) |
Modifier and Type | Method and Description |
---|---|
protected T |
compositeKeyRecord(java.lang.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(java.util.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(java.util.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> java.util.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.
|
java.util.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
|
java.lang.Class<P> |
getType()
Get the underlying POJO type
|
void |
insert(java.util.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(java.util.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, java.lang.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 final Settings settings()
DAO
This method is a convenient way of accessing
configuration().settings()
.
public final SQLDialect dialect()
DAO
SQLDialect
wrapped by this context.
This method is a convenient way of accessing
configuration().dialect()
.
public final 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 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(java.util.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(java.util.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(java.util.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(java.util.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 java.util.List<P> findAll()
DAO
public final P findById(T id)
DAO
public final <Z> java.util.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 java.lang.Class<P> getType()
DAO
protected final T compositeKeyRecord(java.lang.Object... values)
Copyright © 2015. All Rights Reserved.