A simple application does not work correctly with the following entity structure
@Entity(name="some_table")
@Inheritance(strategy= InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn( name="TYPE", discriminatorType=DiscriminatorType.STRING )
abstract class EntityBase {
@Id
@GeneratedValue(strategy= GenerationType.AUTO)
@Column
private int id;
}
@Entity
@DiscriminatorValue("EntityA")
@Cacheable
class EntityA extends EntityBase {
@Column
private int aColumn;
...
}
@Entity
@DiscriminatorValue("EntityB")
@Cacheable
class EntityB extends EntityBase {
@Column
private int bColumn;
...
}
@Entity(name="holder_table")
@Cacheable
class HolderEntity {
@Id
@GeneratedValue(strategy= GenerationType.AUTO)
@Column
private int id;
@ManyToOne(fetch=FetchType.LAZY)
EntityBase holdedEntity;
...
}
For first boot or without cache, everything works well
After loading the HolderEntity instance from the cache, holdedEntity initialized with an entity of type EntityBase (abstract class).
pseudo code:
def a = HolderEntity.get(1)
assert a.holdedEntity.class!=EntityBase
a = HolderEntity.get(1)
assert a.holdedEntity.class!=EntityBase
hibernate :
( EntityBase) (final Type [] types = subclassPersister.getPropertyTypes(), DefaultLoadEventListener)
SessionImpl.internalLoad(String entityName, Serializable id, boolean eager, boolean nullable) witch "" init
holdedEntity
, AbstractEntityPersister.EntityMetamodel. , ,
L2 ?
4.3.8 (4.3.6 4.3.11 )
: