added support for JPA 2.1 unwrap method on EntityManagerFactory interface

This commit is contained in:
Juergen Hoeller 2011-12-05 21:34:44 +00:00
parent 66b4eb16a5
commit 27471e0555
1 changed files with 7 additions and 0 deletions

View File

@ -507,6 +507,13 @@ public abstract class AbstractEntityManagerFactoryBean implements
// Use hashCode of EntityManagerFactory proxy.
return System.identityHashCode(proxy);
}
else if (method.getName().equals("unwrap")) {
// Handle JPA 2.1 unwrap method - could be a proxy match.
Class targetClass = (Class) args[0];
if (targetClass == null || targetClass.isInstance(proxy)) {
return proxy;
}
}
return this.entityManagerFactoryBean.invokeProxyMethod(method, args);
}
catch (InvocationTargetException ex) {