In my domain model, I have an abstract entity inherited by two concrete entities A and B. The abstract entity hold an entity X in order to be accessible for the two sub-classes. The relation is bi-directional. So the entity X hold an instance of the abstract entity. Of course, the real instance is either A or B.
@Entity @Inheritance(strategy = JOINED) public abstract class AbstractEntity implements Serializable { @OneToMany(mappedBy = "abstractEntity") private List<EntityX> xEntities = new ArrayList<EntityX>(); ... }
@Entity @Audited public class EntityX implements Serializable { @ManyToOne(optional = false) @JoinColumn(name = "ID_ENT", nullable = false) @ForeignKey(name = "FK_x__a") private AbstractEntity abstractEntity; }
@Entity @Audited public class EntityA extends AbstractEntity { ... } @Entity @Audited public class EntityB extends AbstractEntity { ... }
I use Dozer to map these entities with themselves in order to "break" the hibernate instrumentation and push them on client side (GWT).
Whith "classic" Hibernate, all works fine : Dozer cross the beans model to duplicate it.
But, when I use the Envers AuditReader for querying versioned entities, I get an InstantiationException. It come from the fact that the instance of X try to instantiate an instance of AbstractEntity.
Does it come from the fact that Envers use Lazy loading even when Eager is specified ?
PS : Of course, I need the bi-directional navigation from AbstractEntity to EntityX.
|