|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.dao.support.DaoSupport org.springframework.orm.jpa.support.JpaDaoSupport
public abstract class JpaDaoSupport
Convenient super class for JPA data access objects. Intended for JpaTemplate usage. Alternatively, JPA-based DAOs can be coded against the plain JPA EntityManagerFactory/EntityManager API.
Requires an EntityManagerFactory or EntityManager to be set, providing a JpaTemplate based on it to subclasses. Can alternatively be initialized directly via a JpaTemplate, to reuse the latter's settings such as the EntityManagerFactory, JpaDialect, flush mode, etc.
This class will create its own JpaTemplate if an EntityManagerFactory
or EntityManager reference is passed in. A custom JpaTemplate instance
can be used through overriding createJpaTemplate
.
setEntityManagerFactory(javax.persistence.EntityManagerFactory)
,
setEntityManager(javax.persistence.EntityManager)
,
createJpaTemplate(javax.persistence.EntityManagerFactory)
,
setJpaTemplate(org.springframework.orm.jpa.JpaTemplate)
,
JpaTemplate
Field Summary |
---|
Fields inherited from class org.springframework.dao.support.DaoSupport |
---|
logger |
Constructor Summary | |
---|---|
JpaDaoSupport()
|
Method Summary | |
---|---|
protected void |
checkDaoConfig()
Abstract subclasses must override this to check their configuration. |
protected JpaTemplate |
createJpaTemplate(javax.persistence.EntityManager entityManager)
Create a JpaTemplate for the given EntityManager. |
protected JpaTemplate |
createJpaTemplate(javax.persistence.EntityManagerFactory entityManagerFactory)
Create a JpaTemplate for the given EntityManagerFactory. |
JpaTemplate |
getJpaTemplate()
Return the JpaTemplate for this DAO, pre-initialized with the EntityManagerFactory or set explicitly. |
void |
setEntityManager(javax.persistence.EntityManager entityManager)
Set the JPA EntityManager to be used by this DAO. |
void |
setEntityManagerFactory(javax.persistence.EntityManagerFactory entityManagerFactory)
Set the JPA EntityManagerFactory to be used by this DAO. |
void |
setJpaTemplate(JpaTemplate jpaTemplate)
Set the JpaTemplate for this DAO explicitly, as an alternative to specifying a EntityManagerFactory. |
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 |
Constructor Detail |
---|
public JpaDaoSupport()
Method Detail |
---|
public final void setEntityManagerFactory(javax.persistence.EntityManagerFactory entityManagerFactory)
protected JpaTemplate createJpaTemplate(javax.persistence.EntityManagerFactory entityManagerFactory)
Can be overridden in subclasses to provide a JpaTemplate instance with different configuration, or a custom JpaTemplate subclass.
entityManagerFactory
- the JPA EntityManagerFactory to create a JpaTemplate for
setEntityManagerFactory(javax.persistence.EntityManagerFactory)
public final void setEntityManager(javax.persistence.EntityManager entityManager)
protected JpaTemplate createJpaTemplate(javax.persistence.EntityManager entityManager)
Can be overridden in subclasses to provide a JpaTemplate instance with different configuration, or a custom JpaTemplate subclass.
entityManager
- the JPA EntityManager to create a JpaTemplate for
setEntityManagerFactory(javax.persistence.EntityManagerFactory)
public final void setJpaTemplate(JpaTemplate jpaTemplate)
public final JpaTemplate getJpaTemplate()
protected final void checkDaoConfig()
DaoSupport
Implementors should be marked as final
checkDaoConfig
in class DaoSupport
|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |