I'm trying to figure out how best to implement polymorphic one-to-many sleep mode.
For example:
@MappedSuperclass public class BaseEntity { Integer id; // etc... } @Entity public class Author extends BaseEntity {} @Entity public class Post extends BaseEntity {} @Entity public class Comment extends BaseEntity {}
And now I would also like to save audit information with the following class:
@Entity public class AuditEvent { @ManyToOne
What is the appropriate mapping for auditEvent.entity ? Also, how does Hibernate actually persist in this? Will a series of connection tables be generated ( AuditEvent_Author , AuditEvent_Post , AuditEvent_Comment ) or is there a better way?
Note that I would prefer that my other entity classes do not display the other side of the connection (for example, List<AuditEvent> events on BaseEntity ), but if this is the cleanest implementation method, then that will be enough.
java hibernate
Marty pitt
source share