title: Hibernate: override entity getter to add annotations
body: <p>I need to override a getter of an entity object, on which the db column is defined, in it's superclass, so I can add additional annotations.</p>
  
  <p>Example:</p>
  
  <pre><code>@MappedSuperclass
  public class Person {
  
      String name;
  
      @Column(name = "name")
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  }
  
  @Entity
  @Table(name="employee")
  @XmlType(name="employee")
  public class Employee extends Person {
  
      @Override
      @XmlAttribute(name = "name")
      public String getName() {
          return super.getName();
      }
  
  }
  </code></pre>
  
  <p>Class <code>Person</code> contains common attributes for several entities. Class <code>Employee</code> extends person and defines a database table (table per class strategy). I also want to serialize class <code>Employee</code> to XML, so I need to add additional annotations to its getters, and therefore I'm overriding them.</p>
  
  <p>The problem is that when I try to run this code, I get a Hibernate <code>MappingException</code> saying: Duplicate property mapping of name found in Employee.</p>
  
  <p>Is there a way to tell Hibernate that the name getter in Employee is not duplicate but just overriden (perhaps with some annotation). Or is there another way to do what I need?</p>