|
|
|
@ -125,7 +125,7 @@ public abstract class EntityManagerFactoryUtils {
@@ -125,7 +125,7 @@ public abstract class EntityManagerFactoryUtils {
|
|
|
|
|
* Obtain a JPA EntityManager from the given factory. Is aware of a corresponding |
|
|
|
|
* EntityManager bound to the current thread, e.g. when using JpaTransactionManager. |
|
|
|
|
* <p>Note: Will return {@code null} if no thread-bound EntityManager found! |
|
|
|
|
* @param emf EntityManagerFactory to create the EntityManager with |
|
|
|
|
* @param emf the EntityManagerFactory to create the EntityManager with |
|
|
|
|
* @return the EntityManager, or {@code null} if none found |
|
|
|
|
* @throws DataAccessResourceFailureException if the EntityManager couldn't be obtained |
|
|
|
|
* @see JpaTransactionManager |
|
|
|
@ -141,7 +141,7 @@ public abstract class EntityManagerFactoryUtils {
@@ -141,7 +141,7 @@ public abstract class EntityManagerFactoryUtils {
|
|
|
|
|
* Obtain a JPA EntityManager from the given factory. Is aware of a corresponding |
|
|
|
|
* EntityManager bound to the current thread, e.g. when using JpaTransactionManager. |
|
|
|
|
* <p>Note: Will return {@code null} if no thread-bound EntityManager found! |
|
|
|
|
* @param emf EntityManagerFactory to create the EntityManager with |
|
|
|
|
* @param emf the EntityManagerFactory to create the EntityManager with |
|
|
|
|
* @param properties the properties to be passed into the {@code createEntityManager} |
|
|
|
|
* call (may be {@code null}) |
|
|
|
|
* @return the EntityManager, or {@code null} if none found |
|
|
|
@ -163,7 +163,7 @@ public abstract class EntityManagerFactoryUtils {
@@ -163,7 +163,7 @@ public abstract class EntityManagerFactoryUtils {
|
|
|
|
|
* Obtain a JPA EntityManager from the given factory. Is aware of a corresponding |
|
|
|
|
* EntityManager bound to the current thread, e.g. when using JpaTransactionManager. |
|
|
|
|
* <p>Same as {@code getEntityManager}, but throwing the original PersistenceException. |
|
|
|
|
* @param emf EntityManagerFactory to create the EntityManager with |
|
|
|
|
* @param emf the EntityManagerFactory to create the EntityManager with |
|
|
|
|
* @param properties the properties to be passed into the {@code createEntityManager} |
|
|
|
|
* call (may be {@code null}) |
|
|
|
|
* @return the EntityManager, or {@code null} if none found |
|
|
|
@ -182,7 +182,7 @@ public abstract class EntityManagerFactoryUtils {
@@ -182,7 +182,7 @@ public abstract class EntityManagerFactoryUtils {
|
|
|
|
|
* Obtain a JPA EntityManager from the given factory. Is aware of a corresponding |
|
|
|
|
* EntityManager bound to the current thread, e.g. when using JpaTransactionManager. |
|
|
|
|
* <p>Same as {@code getEntityManager}, but throwing the original PersistenceException. |
|
|
|
|
* @param emf EntityManagerFactory to create the EntityManager with |
|
|
|
|
* @param emf the EntityManagerFactory to create the EntityManager with |
|
|
|
|
* @param properties the properties to be passed into the {@code createEntityManager} |
|
|
|
|
* call (may be {@code null}) |
|
|
|
|
* @param synchronizedWithTransaction whether to automatically join ongoing |
|
|
|
@ -268,7 +268,6 @@ public abstract class EntityManagerFactoryUtils {
@@ -268,7 +268,6 @@ public abstract class EntityManagerFactoryUtils {
|
|
|
|
|
|
|
|
|
|
// Use same EntityManager for further JPA operations within the transaction.
|
|
|
|
|
// Thread-bound object will get removed by synchronization at transaction completion.
|
|
|
|
|
logger.debug("Registering transaction synchronization for JPA EntityManager"); |
|
|
|
|
emHolder = new EntityManagerHolder(em); |
|
|
|
|
if (synchronizedWithTransaction) { |
|
|
|
|
Object transactionData = prepareTransaction(em, emf); |
|
|
|
@ -329,7 +328,7 @@ public abstract class EntityManagerFactoryUtils {
@@ -329,7 +328,7 @@ public abstract class EntityManagerFactoryUtils {
|
|
|
|
|
* Apply the current transaction timeout, if any, to the given JPA Query object. |
|
|
|
|
* <p>This method sets the JPA 2.0 query hint "javax.persistence.query.timeout" accordingly. |
|
|
|
|
* @param query the JPA Query object |
|
|
|
|
* @param emf JPA EntityManagerFactory that the Query was created for |
|
|
|
|
* @param emf the JPA EntityManagerFactory that the Query was created for |
|
|
|
|
*/ |
|
|
|
|
public static void applyTransactionTimeout(Query query, EntityManagerFactory emf) { |
|
|
|
|
EntityManagerHolder emHolder = (EntityManagerHolder) TransactionSynchronizationManager.getResource(emf); |
|
|
|
@ -415,7 +414,6 @@ public abstract class EntityManagerFactoryUtils {
@@ -415,7 +414,6 @@ public abstract class EntityManagerFactoryUtils {
|
|
|
|
|
*/ |
|
|
|
|
public static void closeEntityManager(@Nullable EntityManager em) { |
|
|
|
|
if (em != null) { |
|
|
|
|
logger.debug("Closing JPA EntityManager"); |
|
|
|
|
try { |
|
|
|
|
if (em.isOpen()) { |
|
|
|
|
em.close(); |
|
|
|
|