HHH-16565 Clear PC entry for 2LC inconsistent return class entities

This commit is contained in:
Marco Belladelli 2023-05-17 09:45:40 +02:00
parent f0affe7804
commit e84dfb2a8c
1 changed files with 4 additions and 5 deletions

View File

@ -317,12 +317,11 @@ public class CacheEntityLoaderHelper {
Object entity = convertCacheEntryToEntity( entry, entityKey.getIdentifier(), source, persister, instanceToLoad, entityKey );
if ( !persister.isInstance( entity ) ) {
// Cleanup the inconsistent return class entity from the persistence context
final PersistenceContext persistenceContext = source.getPersistenceContext();
persistenceContext.removeEntry( entity );
persistenceContext.removeEntity( entityKey );
return null;
// throw new WrongClassException(
// "loaded object was of wrong class " + entity.getClass(),
// entityKey.getIdentifier(),
// persister.getEntityName()
// );
}
return entity;