title: JPA Entity by extending a MappedSuperclass POJO
body: <p>I have the following class</p>
  
  <pre><code>@MappedSuperclass
  public class Keyword {
          private Integer code;
          private Integer rating;
  
          public Keyword() {}
  
          public Integer getCode() {
              return this.code;
          }
  
          public Integer getRating() {
              return this.rating;
          }
  
          public void setCode(Integer code) {
              this.code = code;
          }
  
          public void setRating(Integer rating) {
              this.rating = rating;
          }
  }
  </code></pre>
  
  <p>I <s>want</s> to create an <code>Entity</code> by extending this class and I want to set an already existing field as the primary key (I don't want to create new fields), so I tried to do something like this:</p>
  
  <pre><code>@Entity
  @Table(name = "keyword")
  //@AttributeOverride(name = "code", column = @Column(name = "code"))
  public class MyKeyword extends Keyword {
      @Override
      @Id
      @GeneratedValue
      public Integer getCode() {
          return super.getCode();
      }
  }
  </code></pre>
  
  <p>This gives me the following error when ran</p>
  
  <blockquote>
    <p>Caused by: org.hibernate.MappingException: Repeated column in mapping
    for entity: com.foo.model.MyKeyword column: code (should be mapped
    with insert="false" update="false")</p>
  </blockquote>
  
  <p>Any idea how can I properly configure this up? Keep in mind I have no access to the MappedSuperclass, I can't modify it whatsoever.</p>