Skip to content

Commit 27471e0

Browse files
committed
added support for JPA 2.1 unwrap method on EntityManagerFactory interface
1 parent 66b4eb1 commit 27471e0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,13 @@ else if (method.getName().equals("hashCode")) {
507507
// Use hashCode of EntityManagerFactory proxy.
508508
return System.identityHashCode(proxy);
509509
}
510+
else if (method.getName().equals("unwrap")) {
511+
// Handle JPA 2.1 unwrap method - could be a proxy match.
512+
Class targetClass = (Class) args[0];
513+
if (targetClass == null || targetClass.isInstance(proxy)) {
514+
return proxy;
515+
}
516+
}
510517
return this.entityManagerFactoryBean.invokeProxyMethod(method, args);
511518
}
512519
catch (InvocationTargetException ex) {

0 commit comments

Comments
 (0)