We are using a proxy for each entity (bytebuddy), also we created a Tuplizer and an Instantiator for Hibernate.
This works for loading an entity from a DB, for creating a new entity and for modifying an entity but not for deleting. Create, load and modify seams seems to use *SessionImpl.contains(entityName, object)* and delete uses *SessionImpl.contains(object)*. Both methods are trying to load an EntityPersister (Line 2058 and 2025) but the method without the entityName parameter (Line 1982) tries to load the persister by class-name instead of the entity-name.
Bugfix is on line "*getSessionFactory().getMetamodel().entityPersister*"
Current: {code:title=SessionImpl.java|borderStyle=solid} @Override public boolean contains(Object object) { //... if ( entry == null ) { if ( !HibernateProxy.class.isInstance( object ) && persistenceContext.getEntry( object ) == null ) { // check if it is even an entity -> if not throw an exception (per JPA) try { final String entityName = getEntityNameResolver().resolveEntityName( object ); if ( entityName == null ) { throw new IllegalArgumentException( "Could not resolve entity-name [" + object + "]" ); } getSessionFactory().getMetamodel().entityPersister( object.getClass() ); } catch (HibernateException e) { throw new IllegalArgumentException( "Not an entity [" + object.getClass() + "]", e ); } } return false; } //... } {code}
Fixed: {code:title=SessionImpl.java|borderStyle=solid} @Override public boolean contains(Object object) { //... if ( entry == null ) { if ( !HibernateProxy.class.isInstance( object ) && persistenceContext.getEntry( object ) == null ) { // check if it is even an entity -> if not throw an exception (per JPA) try { final String entityName = getEntityNameResolver().resolveEntityName( object ); if ( entityName == null ) { throw new IllegalArgumentException( "Could not resolve entity-name [" + object + "]" ); } getSessionFactory().getMetamodel().entityPersister( entityName ); } catch (HibernateException e) { throw new IllegalArgumentException( "Not an entity [" + object.getClass() + "]", e ); } } return false; } //... } {code}
I am trying to create a simple test for that.. |
|