|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.springframework.dao.support.DaoSupport
org.springframework.orm.jpa.support.JpaDaoSupport
org.dellroad.stuff.dao.AbstractDAO<T>
T - persistent instance typepublic abstract class AbstractDAO<T>
Support superclass for JPA DAO implementations.
| Nested Class Summary | |
|---|---|
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. |
| Field Summary | |
|---|---|
protected Logger |
log
|
protected Class<T> |
type
Persistent instance type. |
| Fields inherited from class org.springframework.dao.support.DaoSupport |
|---|
logger |
| Constructor Summary | |
|---|---|
protected |
AbstractDAO(Class<T> type)
Constructor. |
protected |
AbstractDAO(Class<T> type,
EntityManagerFactory entityManagerFactory)
Constructor. |
protected |
AbstractDAO(Class<T> type,
JpaTemplate jpaTemplate)
Constructor. |
| Method Summary | ||
|---|---|---|
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()
Clear the session cache. |
|
void |
delete(T obj)
Delete the given instance from the persistent store. |
|
void |
detach(Object obj)
Evict an object from the session cache. |
|
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()
Flush outstanding changes to the persistent store. |
|
List<T> |
getAll()
Get all instances. |
|
protected
|
getBy(QueryCallback<R> callback)
Search using a QueryCallback. |
|
T |
getById(long id)
Get an instance by ID. |
|
T |
getReference(long id)
Get a reference to an instance by ID. |
|
boolean |
isReadOnly()
Determine if the current transaction is read-only. |
|
T |
merge(T obj)
Merge the given object into the current session. |
|
void |
refresh(T obj)
Refresh the given object from the database. |
|
void |
save(T obj)
Save a newly created instance. |
|
void |
setFlushMode(FlushModeType flushMode)
Set flush mode. |
|
| Methods inherited from class org.springframework.orm.jpa.support.JpaDaoSupport |
|---|
checkDaoConfig, createJpaTemplate, createJpaTemplate, getJpaTemplate, setEntityManager, setEntityManagerFactory, setJpaTemplate |
| Methods inherited from class org.springframework.dao.support.DaoSupport |
|---|
afterPropertiesSet, initDao |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final Logger log
protected final Class<T> type
| Constructor Detail |
|---|
protected AbstractDAO(Class<T> type)
type - persistent instance type
protected AbstractDAO(Class<T> type,
EntityManagerFactory entityManagerFactory)
type - persistent instance typeentityManagerFactory - EntityManagerFactory from which to create the JpaTemplate used by this instance
protected AbstractDAO(Class<T> type,
JpaTemplate jpaTemplate)
type - persistent instance typejpaTemplate - JpaTemplate to be used by this instance| Method Detail |
|---|
public T getById(long id)
DAO
getById in interface DAO<T>public List<T> getAll()
DAO
getAll in interface DAO<T>public T getReference(long id)
DAONote if the instance does not exist, then an exception may be thrown either here or later upon first access.
getReference in interface DAO<T>
protected List<T> find(String queryString,
Object... params)
protected T findUnique(String queryString,
Object... params)
protected <R> R getBy(QueryCallback<R> callback)
QueryCallback.
protected int bulkUpdate(UpdateCallback callback)
public void save(T obj)
DAO
save in interface DAO<T>public void delete(T obj)
DAO
delete in interface DAO<T>public T merge(T obj)
DAO
merge in interface DAO<T>public void refresh(T obj)
DAO
refresh in interface DAO<T>public void detach(Object obj)
DAO
detach in interface DAO<T>public void flush()
DAO
flush in interface DAO<T>public void setFlushMode(FlushModeType flushMode)
DAO
setFlushMode in interface DAO<T>public void clear()
DAO
clear in interface DAO<T>public boolean isReadOnly()
DAO
isReadOnly in interface DAO<T>protected T cast(Object obj)
protected List<T> castList(List<?> list)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||