To acquire spring ApplicationContext
:
<bean id="springApplicationContextProvider" class="com.isomorphic.spring.SpringApplicationContextProvider" />To acquire
EntityManagerFactory
: <bean id="REFERENCE_TO_ENTITY_MANAGER_FACTORY" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> ... </bean> To acquire JpaTransactionManager
: <bean id="REFERENCE_TO_TRANSACTION_MANAGER" class="org.springframework.orm.jpa.JpaTransactionManager"> <property name="entityManagerFactory" ref="REFERENCE_TO_ENTITY_MANAGER_FACTORY" /> </bean> protected jakarta.persistence.EntityManagerFactory
EntityManagerFactory
.protected org.springframework.orm.jpa.JpaTransactionManager
JpaTransactionManager
.ENTITY_MANAGER, ENTITY_MANAGER_FACTORY, JPA_ENTITY_MANAGER, JPA_ENTITY_MANAGER_FACTORY, JPA_PERSISTENCE_UNIT_NAME, JPA_TRANSACTION, PERSISTENCE_UNIT_NAME, TRANSACTION
EMFProviderSpring(String entityManagerFactory, String transaction)
EMFProviderSpring(Properties config)
void
jakarta.persistence.EntityManagerFactory
get()
EntityManagerFactory
.jakarta.persistence.EntityManager
EntityManager
created using factory.getTransaction(jakarta.persistence.EntityManager em)
void
returnEntityManager(jakarta.persistence.EntityManager em)
EntityManager
.void
EntityManagerFactory
.JpaTransactionManager
.EntityManagerFactory
and JpaTransactionManager
in spring application context.EntityManagerFactory
and JpaTransactionManager
in spring application context.config
- Properties
for provider configuration.entityManagerFactory
- String
name of context reference to entity manager factory.transaction
- String
name of context reference to transaction manager.EntityManagerFactory
.get
in interface EMFProviderInterface
EntityManagerFactory
acquired from spring application context.EntityManager
created using factory.getEntityManager
in interface EMFProviderInterface
EntityManager
for persistence operations.jakarta.persistence.PersistenceException
- if unable to acquire EntityManager
.EntityManager
.returnEntityManager
in interface EMFProviderInterface
em
- EntityManager
which should be closed. Acquires transaction via JpaTransactionManager.getTransaction (null)
.
getTransaction
in interface EMFProviderInterface
em
- EntityManager
needed if joining to existing transaction or starting transaction locally.Object
Already started transaction for persistence operations.jakarta.persistence.PersistenceException
- if unable to acquire or open transaction.Exception
- if unable to acquire or open transaction.commitTransaction
in interface EMFProviderInterface
tx
- Object
transaction to be committed.Exception
- occurred while committing transaction.rollbackTransaction
in interface EMFProviderInterface
tx
- Object
transaction to be rolled back.