2 Replies Latest reply on Jul 31, 2006 4:35 AM by pouriya zarbafian

    Override Primary Key Mapping

    pouriya zarbafian Newbie

      Hi,
      I am trying to override the primary key mapping in subclasses. The problem is that the table created for the subclass keeps both two columns: the primary key of the superclass and the overriden mapping.
      Here is the code:

      @Entity
      @Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
      public abstract class MyAbstractSuper {
      private Long id_MyAbstractSuper;
      @Id
      public Long getId_MyAbstractSuper() {
      return id_MyAbstractSuper;
      }
      public void setId_MyAbstractSuper(Long id_MyAbstractSuper) {
      this.id_MyAbstractSuper = id_MyAbstractSuper;
      }
      }

      @Entity
      @Table(name="MySubClass")
      @AttributeOverride(name="id_MyAbstractSuper",column=@Column(name="id_MySubClass"))
      public class MySubClass extends MyAbstractSuperclass {

      @Override
      public Long getId_MyAbstractSuperclass(){
      return super.getId_MyAbstractSuperclass();
      }
      }

      I read that there was a bug with javassist and tried to replace it with cglib but the problem still remains.

      Thank you.