PersistenceAnnotationBeanPostProcessor correctly detects JPA 2.1 synchronization attribute

Issue: SPR-12396
This commit is contained in:
Juergen Hoeller
2014-10-30 15:15:34 +01:00
parent fc7e60678c
commit a181b40e39
3 changed files with 506 additions and 13 deletions

View File

@@ -82,7 +82,7 @@ import org.springframework.util.StringUtils;
* with the "unitName" attribute, or no attribute at all (for the default unit).
* If those annotations are present with the "name" attribute at the class level,
* they will simply be ignored, since those only serve as deployment hint
* (as per the Java EE 5 specification).
* (as per the Java EE specification).
*
* <p>This post-processor can either obtain EntityManagerFactory beans defined
* in the Spring application context (the default), or obtain EntityManagerFactory
@@ -167,9 +167,9 @@ public class PersistenceAnnotationBeanPostProcessor
implements InstantiationAwareBeanPostProcessor, DestructionAwareBeanPostProcessor,
MergedBeanDefinitionPostProcessor, PriorityOrdered, BeanFactoryAware, Serializable {
/* Check JPA 2.1 PersistenceContext.synchronizationType attribute */
private static final Method synchronizationTypeAttribute =
ClassUtils.getMethodIfAvailable(PersistenceContext.class, "synchronizationType");
/* Check JPA 2.1 PersistenceContext.synchronization() attribute */
private static final Method synchronizationAttribute =
ClassUtils.getMethodIfAvailable(PersistenceContext.class, "synchronization");
private Object jndiEnvironment;
@@ -231,8 +231,8 @@ public class PersistenceAnnotationBeanPostProcessor
* for the {@link #setDefaultPersistenceUnitName default persistence unit}
* will be taken (by default, the value mapped to the empty String),
* or simply the single persistence unit if there is only one.
* <p>This is mainly intended for use in a Java EE 5 environment, with all
* lookup driven by the standard JPA annotations, and all EntityManagerFactory
* <p>This is mainly intended for use in a Java EE environment, with all lookup
* driven by the standard JPA annotations, and all EntityManagerFactory
* references obtained from JNDI. No separate EntityManagerFactory bean
* definitions are necessary in such a scenario.
* <p>If no corresponding "persistenceContexts"/"extendedPersistenceContexts"
@@ -240,7 +240,7 @@ public class PersistenceAnnotationBeanPostProcessor
* EntityManagers built on top of the EntityManagerFactory defined here.
* Note that those will be Spring-managed EntityManagers, which implement
* transaction synchronization based on Spring's facilities.
* If you prefer the Java EE 5 server's own EntityManager handling,
* If you prefer the Java EE server's own EntityManager handling,
* specify corresponding "persistenceContexts"/"extendedPersistenceContexts".
*/
public void setPersistenceUnits(Map<String, String> persistenceUnits) {
@@ -258,11 +258,11 @@ public class PersistenceAnnotationBeanPostProcessor
* for the {@link #setDefaultPersistenceUnitName default persistence unit}
* will be taken (by default, the value mapped to the empty String),
* or simply the single persistence unit if there is only one.
* <p>This is mainly intended for use in a Java EE 5 environment, with all
* <p>This is mainly intended for use in a Java EE environment, with all
* lookup driven by the standard JPA annotations, and all EntityManager
* references obtained from JNDI. No separate EntityManagerFactory bean
* definitions are necessary in such a scenario, and all EntityManager
* handling is done by the Java EE 5 server itself.
* handling is done by the Java EE server itself.
*/
public void setPersistenceContexts(Map<String, String> persistenceContexts) {
this.persistenceContexts = persistenceContexts;
@@ -279,11 +279,11 @@ public class PersistenceAnnotationBeanPostProcessor
* for the {@link #setDefaultPersistenceUnitName default persistence unit}
* will be taken (by default, the value mapped to the empty String),
* or simply the single persistence unit if there is only one.
* <p>This is mainly intended for use in a Java EE 5 environment, with all
* <p>This is mainly intended for use in a Java EE environment, with all
* lookup driven by the standard JPA annotations, and all EntityManager
* references obtained from JNDI. No separate EntityManagerFactory bean
* definitions are necessary in such a scenario, and all EntityManager
* handling is done by the Java EE 5 server itself.
* handling is done by the Java EE server itself.
*/
public void setExtendedPersistenceContexts(Map<String, String> extendedPersistenceContexts) {
this.extendedPersistenceContexts = extendedPersistenceContexts;
@@ -632,8 +632,8 @@ public class PersistenceAnnotationBeanPostProcessor
}
this.unitName = pc.unitName();
this.type = pc.type();
this.synchronizedWithTransaction = (synchronizationTypeAttribute == null ||
"SYNCHRONIZED".equals(ReflectionUtils.invokeMethod(synchronizationTypeAttribute, pc).toString()));
this.synchronizedWithTransaction = (synchronizationAttribute == null ||
"SYNCHRONIZED".equals(ReflectionUtils.invokeMethod(synchronizationAttribute, pc).toString()));
this.properties = properties;
}
else {