@PersistenceContext
)@Deprecated public abstract class JpaAccessor extends EntityManagerFactoryAccessor implements InitializingBean
Not intended to be used directly.
See JpaTemplate
and JpaInterceptor
.
EntityManagerFactoryAccessor.setEntityManagerFactory(javax.persistence.EntityManagerFactory)
,
setEntityManager(javax.persistence.EntityManager)
,
setJpaDialect(org.springframework.orm.jpa.JpaDialect)
,
setFlushEager(boolean)
,
JpaTemplate
,
JpaInterceptor
,
JpaDialect
logger
Constructor and Description |
---|
JpaAccessor()
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet()
Deprecated.
Eagerly initialize the JPA dialect, creating a default one
for the specified EntityManagerFactory if none set.
|
protected void |
flushIfNecessary(EntityManager em,
boolean existingTransaction)
Deprecated.
Flush the given JPA entity manager if necessary.
|
EntityManager |
getEntityManager()
Deprecated.
Return the JPA EntityManager to use.
|
JpaDialect |
getJpaDialect()
Deprecated.
Return the JPA dialect to use for this accessor.
|
boolean |
isFlushEager()
Deprecated.
Return if this accessor should flush changes to the database eagerly.
|
void |
setEntityManager(EntityManager entityManager)
Deprecated.
Set the JPA EntityManager to use.
|
void |
setFlushEager(boolean flushEager)
Deprecated.
Set if this accessor should flush changes to the database eagerly.
|
void |
setJpaDialect(JpaDialect jpaDialect)
Deprecated.
Set the JPA dialect to use for this accessor.
|
RuntimeException |
translateIfNecessary(RuntimeException ex)
Deprecated.
Convert the given runtime exception to an appropriate exception from the
org.springframework.dao hierarchy if necessary, or
return the exception itself if it is not persistence related |
createEntityManager, getEntityManagerFactory, getJpaPropertyMap, getPersistenceUnitName, getTransactionalEntityManager, setBeanFactory, setEntityManagerFactory, setJpaProperties, setJpaPropertyMap, setPersistenceUnitName
public void setEntityManager(EntityManager entityManager)
public EntityManager getEntityManager()
public void setJpaDialect(JpaDialect jpaDialect)
The dialect object can be used to retrieve the underlying JDBC connection, for example.
public JpaDialect getJpaDialect()
Creates a default one for the specified EntityManagerFactory if none set.
public void setFlushEager(boolean flushEager)
Eager flushing leads to immediate synchronization with the database, even if in a transaction. This causes inconsistencies to show up and throw a respective exception immediately, and JDBC access code that participates in the same transaction will see the changes as the database is already aware of them then. But the drawbacks are:
public boolean isFlushEager()
public void afterPropertiesSet()
afterPropertiesSet
in interface InitializingBean
protected void flushIfNecessary(EntityManager em, boolean existingTransaction) throws PersistenceException
em
- the current JPA PersistenceManageexistingTransaction
- if executing within an existing transactionPersistenceException
- in case of JPA flushing errorspublic RuntimeException translateIfNecessary(RuntimeException ex)
org.springframework.dao
hierarchy if necessary, or
return the exception itself if it is not persistence related
Default implementation delegates to the JpaDialect. May be overridden in subclasses.
ex
- runtime exception that occured, which may or may not
be JPA-relatedDataAccessUtils.translateIfNecessary(java.lang.RuntimeException, org.springframework.dao.support.PersistenceExceptionTranslator)