|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.synyx.hades.dao.orm.GenericDaoSupport<T>
T - the type of entity to be handledpublic abstract class GenericDaoSupport<T>
Abstract base class for generic DAOs.
| Nested Class Summary | |
|---|---|
static interface |
GenericDaoSupport.IsNewStrategy
Interface to abstract the ways to determine if a |
static class |
GenericDaoSupport.PersistableIsNewStrategy
Implementation of GenericDaoSupport.IsNewStrategy that assumes the entity handled
implements Persistable and uses Persistable.isNew() for
the GenericDaoSupport.PersistableIsNewStrategy.isNew(Object) check. |
static class |
GenericDaoSupport.ReflectiveIsNewStrategy
GenericDaoSupport.IsNewStrategy implementation that reflectively checks a
Field or Method annotated with Id. |
| Constructor Summary | |
|---|---|
GenericDaoSupport()
|
|
| Method Summary | |
|---|---|
protected void |
assertEntityManagerClass(java.lang.Class<? extends javax.persistence.EntityManager> clazz)
Asserts that the EntityManager implementation being used by the
dao is an instance of the given type. |
protected void |
createIsNewStrategy(java.lang.Class<?> domainClass)
Return whether the given entity is to be regarded as new. |
protected java.lang.String |
getCountQueryString()
Returns the query string to count entities. |
protected java.lang.String |
getDeleteAllQueryString()
Returns the query string to delete all entities. |
protected java.lang.Class<T> |
getDomainClass()
Returns the domain class to handle. |
protected javax.persistence.EntityManager |
getEntityManager()
Returns the EntityManager. |
protected GenericDaoSupport.IsNewStrategy |
getIsNewStrategy()
Returns the strategy how to determine whether an entity is to be regarded as new. |
protected javax.persistence.Query |
getReadAllQuery()
Returns the query to retrieve all entities. |
protected java.lang.String |
getReadAllQueryString()
Returns the query string to retrieve all entities. |
void |
setDomainClass(java.lang.Class<T> domainClass)
Sets the domain class to handle. |
void |
setEntityManager(javax.persistence.EntityManager entityManager)
Setter to inject EntityManager. |
void |
validate()
Callback method to validate the class setup. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public GenericDaoSupport()
| Method Detail |
|---|
protected javax.persistence.EntityManager getEntityManager()
EntityManager.
public void setEntityManager(javax.persistence.EntityManager entityManager)
EntityManager.
entityManager - protected java.lang.Class<T> getDomainClass()
public void setDomainClass(java.lang.Class<T> domainClass)
domainClass - the domain class to setprotected java.lang.String getReadAllQueryString()
protected java.lang.String getDeleteAllQueryString()
protected java.lang.String getCountQueryString()
protected javax.persistence.Query getReadAllQuery()
protected void assertEntityManagerClass(java.lang.Class<? extends javax.persistence.EntityManager> clazz)
EntityManager implementation being used by the
dao is an instance of the given type.
clazz -
java.lang.IllegalArgumentException - if the entity manager is not of the
given typepublic void validate()
protected void createIsNewStrategy(java.lang.Class<?> domainClass)
GenericDaoSupport.PersistableIsNewStrategy if the class implements
Persistable or GenericDaoSupport.ReflectiveIsNewStrategy otherwise.
entity - protected GenericDaoSupport.IsNewStrategy getIsNewStrategy()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||