|
24 | 24 | import java.lang.reflect.Method;
|
25 | 25 | import java.lang.reflect.Proxy;
|
26 | 26 | import java.util.Map;
|
| 27 | + |
27 | 28 | import javax.persistence.EntityManager;
|
28 | 29 | import javax.persistence.EntityManagerFactory;
|
29 | 30 | import javax.persistence.Query;
|
30 | 31 |
|
31 | 32 | import org.apache.commons.logging.Log;
|
32 | 33 | import org.apache.commons.logging.LogFactory;
|
33 |
| - |
34 | 34 | import org.springframework.util.ClassUtils;
|
35 | 35 | import org.springframework.util.CollectionUtils;
|
36 | 36 |
|
|
46 | 46 | *
|
47 | 47 | * @author Juergen Hoeller
|
48 | 48 | * @author Rod Johnson
|
| 49 | + * @author Oliver Gierke |
49 | 50 | * @since 2.0
|
50 | 51 | * @see org.springframework.orm.jpa.LocalEntityManagerFactoryBean
|
51 | 52 | * @see org.springframework.orm.jpa.JpaTransactionManager
|
52 | 53 | */
|
53 | 54 | public abstract class SharedEntityManagerCreator {
|
54 | 55 |
|
| 56 | +private static final Class<?>[] NO_ENTITY_MANAGER_INTERFACES = new Class<?>[0]; |
| 57 | + |
| 58 | + |
55 | 59 | /**
|
56 | 60 | * Create a transactional EntityManager proxy for the given EntityManagerFactory,
|
57 | 61 | * automatically joining ongoing transactions.
|
@@ -84,10 +88,11 @@ public static EntityManager createSharedEntityManager(EntityManagerFactory emf,
|
84 | 88 | */
|
85 | 89 | public static EntityManager createSharedEntityManager(
|
86 | 90 | EntityManagerFactory emf, Map properties, boolean synchronizedWithTransaction) {
|
87 |
| - |
88 |
| -Class emIfc = (emf instanceof EntityManagerFactoryInfo ? |
| 91 | +Class<?> entityManagerInterface = (emf instanceof EntityManagerFactoryInfo ? |
89 | 92 | ((EntityManagerFactoryInfo) emf).getEntityManagerInterface() : EntityManager.class);
|
90 |
| -return createSharedEntityManager(emf, properties, synchronizedWithTransaction, emIfc); |
| 93 | +return createSharedEntityManager(emf, properties, synchronizedWithTransaction, |
| 94 | +(entityManagerInterface == null ? NO_ENTITY_MANAGER_INTERFACES : |
| 95 | +new Class<?>[] { entityManagerInterface })); |
91 | 96 | }
|
92 | 97 |
|
93 | 98 | /**
|
|
0 commit comments