title: Hibernate mapping a second @Embeddable field in a subclass
body: <p>I'm trying to map an @Embeddable object in a subclass whose parent class already has a field of that @Embeddable type.</p>
  
  <p>The hibernate <a href="http://docs.jboss.org/ejb3/app-server/HibernateAnnotations/reference/en/html_single/index.html#d0e483" rel="noreferrer">Embeddable Objects documentation</a> claims I can use the @AttributeOverrides to override the column names of an @Embeddable object:</p>
  
  <p>e.g.</p>
  
  <pre><code>@Entity
  public class Person implements Serializable {
  
      // Persistent component using defaults
      Address homeAddress;
  
      @Embedded
      @AttributeOverrides( {
              @AttributeOverride(name="iso2", column = @Column(name="bornIso2") ),
              @AttributeOverride(name="name", column = @Column(name="bornCountryName") )
      } )
      Country bornIn;
      ...
  }
  </code></pre>
  
  <p>Here's the case I have:</p>
  
  <pre><code> @Embeddable
      public class ContentID implements Serializable {
          @Column(name="contentID")
          private String contentPath;
      }
  
     @MappedSuperclass
     public abstract class BaseDomainObject implements Serializable  {
  
         @Embedded
         private ContentID contentID;
      }
  
  public class Achievement extends BaseDomainObject {
  
      @Embedded
      @AttributeOverrides( {
          @AttributeOverride(name="contentID", column = @Column(name="awardedItem") ),
      } )
      private ContentID awardedItem;
  }   
  </code></pre>
  
  <p>The error I get is:</p>
  
  <blockquote>
    <p>org.hibernate.MappingException:
    Repeated column in mapping for entity:
    Achievement column: contentID (should
    be mapped with insert="false"
    update="false")   at
    org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:652)
      at
    org.hibernate.mapping.PersistentClass.checkPropertyColumnDuplication(PersistentClass.java:674)
      at
    org.hibernate.mapping.PersistentClass.checkPropertyColumnDuplication(PersistentClass.java:670)
      at
    org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:696)
      at
    org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:450)
      at
    org.hibernate.mapping.SingleTableSubclass.validate(SingleTableSubclass.java:43)
      at
    org.hibernate.cfg.Configuration.validate(Configuration.java:1108)
      at
    org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1293)
      at
    org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)</p>
  </blockquote>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>I looked in for Hibernate issues relating to this and the GRAILS project claimed they fixed this issue but their annotation solution doesn't seem to be valid javax.persistence annotations (maybe it's a new version).</p>
  
  <p><a href="http://jira.codehaus.org/browse/GRAILS-3225" rel="noreferrer">JPA @Embeddable/@Embedded throws org.hibernate.MappingException: Repeated column in mapping for entity</a></p>