EntityManager.contains unsupport Entity enhanced by CGLIB
---------------------------------------------------------
Key: JPA-22
URL:
http://opensource.atlassian.com/projects/hibernate/browse/JPA-22
Project: Java Persistence API
Issue Type: Bug
Affects Versions: 1.0.1
Reporter: vangie du
invoke contains() method with a entity enhanced by CGLIB while throw
IllegalArgumentException.
other methods like persit() remove() can config the hibernate interceptor by override the
getEntityName().
public class UnByteCodeProxyInterceptor extends EmptyInterceptor {
private static final long serialVersionUID = -6422637558312349795L;
@Override
public String getEntityName(Object object) {
if (object != null) {
Class<?> cl = object.getClass();
if (ProxyBeanUtils.isProxy(cl)) {
cl = cl.getSuperclass();
}
return cl.getName();
}
else {
return null;
}
}
}
but the contains() not invoke the entityNameResolver to get Entity name.
statement in org.hibernate.ejb.AbstractEntityManagerImpl.contains()
getSession().getSessionFactory().getClassMetadata( entity.getClass() )
change to
getSession().getSessionFactory().getClassMetadata(
((SessionImplementor)getSession()).bestGuessEntityName(entity) )
can workaround this problem.
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira