Bobby Lawrence [https://community.jboss.org/people/blawrence] created the discussion
"EJB3 inheritance and composite key" To view the discussion, visit: https://community.jboss.org/message/717603#717603 -------------------------------------------------------------- Hoping someone can help. I have an app that I'm trying to use EJB3 entities for. One entity represents a Person: @Entity @Table (name = "USERS") @Inheritance (strategy = InheritanceType.JOINED) public class Person { @Column (name = "PERSON_ID") @Id @SequenceGenerator (name = "personIdGenerator", allocationSize = 1, sequenceName = "PERSON_SEQ") @GeneratedValue (generator = "personIdGenerator", strategy = GenerationType.SEQUENCE) private long id; @Column (name = "EMAIL") private String email; @Column (name = "FIRSTNAME") private String firstName; @Column (name = "LASTNAME") private String lastName; ... } Now I have another entity called PrimaryInvestigator that extends Person so I can use the email, lastname, firstname attributes. However the db table for this entity has a composite key representing the person's id and the project the person is associated with: projectId. So this entity requires a composite key. : @Entity @IdClass (PrimaryInvestigatorPK.class) @Table (name = "PROJECT_PI") public class PrimaryInvestigator extends Person { @Column (name = "PROJECT_ID", insertable=false, updatable=false) @Id private long projectId; @Column (name = "BIOSKETCH_FILE_ID") private long biosketchFileId; ... } My IdClass for the PrimaryInvestigator entity looks like this: public class PrimaryInvestigatorPK implements Serializable { public Long userId; public Long projectId; ... } Since part of the composite key is in the Person superclass, I figured I could just add another @Id attribute representing the other part of the composite key and Hibernate would simply use the combination of the two in my composite key. However, every time I try to deploy the EJBs, I get the following exception: org.hibernate.AnnotationException: Unable to define/override @Id(s) on a subclass: org.jlab.mis.apps.mics.valueobjects.PrimaryInvestigator Is what I'm trying to do possible? If so how? I can't use a @MappedSuperclass because I need to be able to persist Person objects by themselves... Any ideas? -------------------------------------------------------------- Reply to this message by going to Community [https://community.jboss.org/message/717603#717603] Start a new discussion in EJB3 at Community [https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029]
_______________________________________________ jboss-user mailing list [email protected] https://lists.jboss.org/mailman/listinfo/jboss-user
