1 Reply Latest reply on Mar 7, 2006 12:36 PM by Emmanuel Bernard

    behavior of @IdClass with @AttributeOverride is not as I exp

    Andreas Berger Newbie

      Hi, I tried following thing:

      @MappedSuperclass
      @IdClass(FootballerPk.class)
      public class Footballer {
       String firstname;
       String lastname;
       //part of the id key
       @Id public String getFirstname() {
       return firstname;
       }
      
       public void setFirstname(String firstname) {
       this.firstname = firstname;
       }
      
       //part of the id key
       @Id public String getLastname() {
       return lastname;
       }
      
       public void setLastname(String lastname) {
       this.lastname = lastname;
       }
      
       public String getClub() {
       return club;
       }
      
       public void setClub(String club) {
       this.club = club;
       }
      
       //appropriate equals() and hashCode() implementation
      }
      
      @Embeddable
      public class FootballerPk implements Serializable {
       String firstname;
       String lastname;
       //same name and type as in Footballer
       public String getFirstname() {
       return firstname;
       }
      
       public void setFirstname(String firstname) {
       this.firstname = firstname;
       }
      
       //same name and type as in Footballer
       public String getLastname() {
       return lastname;
       }
      
       public void setLastname(String lastname) {
       this.lastname = lastname;
       }
      
       //appropriate equals() and hashCode() implementation
      }


      @Entity
      @AttributeOverride( name="firstname", column = @Column(name="new_firstname") )
      public class ExtendedFootballer extends Footballer{
      ...
      }


      But I dont get it to work, that the Attrribute is overwritten.
      All works fine if I dont use @IdClass.

      Is this a possible Bug?