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 3763686aff
commit 7c61867372
No known key found for this signature in database
GPG Key ID: D1D0C3030AE3AA35

View File

@ -317,12 +317,11 @@ private Object processCachedEntry(
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;