Skip to content

Commit b6191f6

Browse files
committed
Direct reference to JPA 2.1 SynchronizationType enum
Issue: SPR-13481
1 parent d187cbc commit b6191f6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

spring-orm/src/main/java/org/springframework/orm/jpa/AbstractEntityManagerFactoryBean.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,6 +36,7 @@
3636
import javax.persistence.EntityManagerFactory;
3737
import javax.persistence.PersistenceException;
3838
import javax.persistence.Query;
39+
import javax.persistence.SynchronizationType;
3940
import javax.persistence.spi.PersistenceProvider;
4041
import javax.persistence.spi.PersistenceUnitInfo;
4142
import javax.sql.DataSource;
@@ -444,7 +445,7 @@ Object invokeProxyMethod(Method method, @Nullable Object[] args) throws Throwabl
444445
return method.invoke(this, args);
445446
}
446447
else if (method.getName().equals("createEntityManager") && args != null && args.length > 0 &&
447-
args[0] != null && args[0].getClass().isEnum() && "SYNCHRONIZED".equals(args[0].toString())) {
448+
args[0] == SynchronizationType.SYNCHRONIZED) {
448449
// JPA 2.1's createEntityManager(SynchronizationType, Map)
449450
// Redirect to plain createEntityManager and add synchronization semantics through Spring proxy
450451
EntityManager rawEntityManager = (args.length > 1 ?

0 commit comments

Comments
 (0)