T - persistent instance typepublic abstract class AbstractDAO<T> extends AbstractBean implements DAO<T>
| Modifier and Type | Class and Description |
|---|---|
protected class |
AbstractDAO.DAOCriteriaListCallback
Convenience subclass of
CriteriaCallback for use by DAO subclasses when returning lists of persistent instances. |
protected class |
AbstractDAO.DAOCriteriaUniqueCallback
Convenience subclass of
CriteriaCallback for use by DAO subclasses when returning a single persistent instance. |
protected class |
AbstractDAO.DAOQueryListCallback
Convenience subclass of
QueryCallback for use by DAO subclasses when returning lists of persistent instances. |
protected class |
AbstractDAO.DAOQueryUniqueCallback
Convenience subclass of
QueryCallback for use by DAO subclasses when returning a single persistent instance. |
| Modifier and Type | Field and Description |
|---|---|
protected Class<T> |
type
Persistent instance type.
|
log| Modifier | Constructor and Description |
|---|---|
protected |
AbstractDAO(Class<T> type)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet()
Initialize bean.
|
protected int |
bulkUpdate(UpdateCallback callback)
Perform a bulk update.
|
protected T |
cast(Object obj)
Cast the given object to this instance's persistent instance type.
|
protected List<T> |
castList(List<?> list)
Cast the given list to a list of this instance's persistent instance type.
|
void |
clear() |
boolean |
contains(T obj) |
void |
delete(T obj) |
void |
detach(Object obj) |
protected List<T> |
find(String queryString,
Object... params)
Find instances using a query string and query parameters.
|
protected T |
findUnique(String queryString,
Object... params)
Find a unique instance using a query string and query parameters.
|
void |
flush() |
List<T> |
getAll() |
protected <R> R |
getBy(QueryCallback<R> callback)
Search using a
QueryCallback. |
T |
getById(long id) |
protected EntityManager |
getEntityManager()
Get the configured
EntityManager. |
T |
getReference(long id) |
Class<T> |
getType() |
boolean |
isReadOnly() |
T |
merge(T obj) |
void |
refresh(T obj) |
void |
save(T obj) |
void |
setEntityManager(EntityManager entityManager)
Set the configured
EntityManager. |
void |
setFlushMode(FlushModeType flushMode) |
destroyprotected EntityManager getEntityManager()
EntityManager.EntityManagerpublic void setEntityManager(EntityManager entityManager)
EntityManager.
This method has a @PersistenceContext annotation and normally
would be invoked automatically by Spring.
entityManager - this DAO's EntityManagerpublic void afterPropertiesSet()
throws Exception
AbstractBean
The implementation in AbstractBean does nothing.
afterPropertiesSet in interface InitializingBeanafterPropertiesSet in class AbstractBeanExceptionpublic T getReference(long id)
getReference in interface DAO<T>protected List<T> find(String queryString, Object... params)
queryString - JPQL query stringparams - query string parametersprotected T findUnique(String queryString, Object... params)
queryString - JPQL query stringparams - query string parametersprotected <R> R getBy(QueryCallback<R> callback)
QueryCallback.R - return typecallback - query callbackprotected int bulkUpdate(UpdateCallback callback)
callback - query callbackpublic void setFlushMode(FlushModeType flushMode)
setFlushMode in interface DAO<T>public boolean isReadOnly()
isReadOnly in interface DAO<T>protected T cast(Object obj)
obj - object to castobj cast to type TCopyright © 2020. All rights reserved.