Simple app works wrong with following entity structure
For first load or without cache everything works well
After loading of HolderEntity instance from cache, holdedEntity field initialised by object with type EntityBase (abstract class).
During loading from cache hibernate construct entity using special logic: for field it detect class type by variable type (it's EntityBase class) instead of discriminator (final Type types = subclassPersister.getPropertyTypes(); in DefaultLoadEventListener) and call method
SessionImpl.internalLoad(String entityName, Serializable id, boolean eager, boolean nullable) witch "instantiate" abstract class and init fields by data from hibernate cache
It works same for lazy & eager loading of holdedEntity Class type stored in AbstractEntityPersister.EntityMetamodel. It looks like, field type for cache is static, but it's should depend on instance of field
How to solve it without disabling of hibernate L2 cache?