1 Reply Latest reply on May 25, 2006 1:05 PM by Cyril JOUI

    Composite and Overlapping PK

    Prabhu Madanagopal Newbie

      Sorry for posting again..
      I have a problem in Composite n Overlapping PK with @EmbeddedId tags
      Is there any other JBOSS specific annotations I need to use? like @Dependable.. Is there any sample code that shows Composite and Overlapping PK mapping?

      I am using JBoss 4.0.4 GA.

      Please have a look at the code snippets and the exception I get.

      Code starts--here--
      @IdClass(com.x.ejb.entity.impl.UserGroupKey.class)
      @Entity
      public class UserGroup {
      ...

      @Id
      @Column(name="GROUPID",
      insertable=false, updatable=false)
      public String getGroupId() {
      return groupId;
      }
      ...
      @Id
      @Column(name="USERID",
      insertable=false, updatable=false)
      public String getUserId() {
      return userId;
      }
      ...
      @EmbeddedId
      public UserGroupKey getPrimaryKey() {
      return primaryKey;
      }
      Code ends--here--

      And UserGroupKey is Embeddable

      On deploying I get
      org.hibernate.MappingException: Repeated column in mapping for entity: com.x.ejb.entity.impl.UserGroup column: groupId (
      should be mapped with insert="false" update="false")

      Thnks, Prabhu

        • 1. Re: Composite and Overlapping PK
          Cyril JOUI Newbie

          Why do you use the primaryKey property ?

          You can do this :

          
          @IdClass(com.x.ejb.entity.impl.UserGroupKey.class)
          @Entity
          public class UserGroup {
          ...
          
          @Id
          @Column(name="GROUPID",
          insertable=false, updatable=false)
          public String getGroupId() {
          return groupId;
          }
          ...
          @Id
          @Column(name="USERID",
          insertable=false, updatable=false)
          public String getUserId() {
          return userId;
          }
          ...
          // don't use this
          /***********************************
          @EmbeddedId
          public UserGroupKey getPrimaryKey() {
          return primaryKey;
          }
          ***********************************/