title: Hibernate Annotations - @MappedSuperclass How to override column identifier
body: <p>I'm working with Hibernate Annotations and the issue that I'm trying to solve goes as follows:</p>
  
  <p>I need to have 2 different @Entity classes with the same columns mapping but with a different Identifier.</p>
  
  <p>The first one should use id as identifier.</p>
  
  <p>The second should use name as identifier.</p>
  
  <p>So, I have an abstract class, annotated with @MappedSuperclass that have all of the columns including id and name, and in addition 2 @Entity classes that extends the super class and overriding the getters of the id and name.</p>
  
  <pre><code>@MappedSuperclass 
  public class MappingBase {
      protected Integer id;
      protected String name;
  
      @Column (name = "ID")
       public void getId() {
            return this.id;
       }
  
      @Column (name = "NAME")
       public void getName() {
            return this.name;
       }              
  }
  
  @Entity
  @Table (name = "TABLE")
  public class Entity1 extends MappingBase {
  
    @Id
    @Column (name = "ID")
    public void getId() {
      return this.id;
    } 
  }
  
  @Entity
  @Table (name = "TABLE")
  public class Entity2 extends MappingBase {
  
    @Id
    @Column (name = "NAME")
    public void getName() {
        return this.name;
    } 
  }
  </code></pre>
  
  <p>Note: I must have the members (id,name) in the super class.
  I know that i can add @Transient to the id and name getters but this means that i must add both of them in each class and it's not a good design :(
  In addition, the following insertable="false, updateable=false can help but i don't understand what is the meaning of this...</p>
  
  <p>Please help me!</p>