title: Hibernate @AttributeOverride columnNames of embedded CompositeType
body: <p>I have an <code>Amount</code> that is mapped to two database columns via a <code>CompositeUserType</code>:</p>
  
  <pre><code>public class Amount  {
      private BigDecimal value;
      private CurrencyCode currency;
  }
  </code></pre>
  
  <p>It is used in this <code>Embeddable</code>:</p>
  
  <pre><code>@Embeddable
  public class AccountBalance {
      private Calendar date;
  
      @Type(type = Amount.TYPE_DEF)
      @Columns(columns = {
          @Column(name = "amount"),
          @Column(name = "currencyCode")})
      private Amount amount;
  }
  </code></pre>
  
  <p>Which is embedded multiple times here:</p>
  
  <pre><code>public class AccountStatement
      @AttributeOverrides(value = {
          @AttributeOverride(name = "date", column = @Column(name = "openingBalanceDate") ),
          @AttributeOverride(name = "amount.amount", column = @Column(name = "openingBalanceAmount") ),
          @AttributeOverride(name = "amount.currencyCode", column = @Column(name = "openingBalanceCurrency") )})
      @Embedded
      @Basic(optional = true)
      private AccountBalance openingBalance;
  
      @AttributeOverrides(value = {
          @AttributeOverride(name = "date", column = @Column(name = "closingBalanceDate") ),
          @AttributeOverride(name = "amount.amount", column = @Column(name = "closingBalanceAmount") ),
          @AttributeOverride(name = "amount.currencyCode", column = @Column(name = "closingBalanceCurrency") )})
      @Embedded
      @Basic(optional = true)
      private AccountBalance closingBalance;
  </code></pre>
  
  <p>Which results in:</p>
  
  <pre><code>Caused by: org.hibernate.MappingException: Repeated column in mapping for entity: ...AccountStatement column: amount (should be mapped with insert="false" update="false")
  </code></pre>
  
  <p>When I add <code>updatable = false, insertable = false</code> into the two columns in <code>AccountBalance</code> (as suggested in the exception text), schema validation is successful, but it fails on inserting data, because it tries to insert a <code>BigDecimal</code> into the next field in the <code>PreparedStatement</code> (not shown in my excerpt) which is a date.</p>
  
  <p>So I want the values to be insertable and updatable.</p>
  
  <p><strong>This leads to the conclusion that hibernate does not handle my <code>AttributeOverrides</code> annotation for the two columns of <code>Amount</code> correctly.</strong></p>
  
  <p>I already tried multiple options:</p>
  
  <ol>
  <li><code>amount.amount</code> and <code>amount.currencyCode</code> (the column names, as in the excerpt)</li>
  <li><code>amount.value</code> and <code>amount.currency</code> (the field names inside <code>Amount</code> and the values returned by <code>getPropertyNames</code> of my <code>CompositeUserType</code></li>
  <li>just <code>amount</code> and <code>currencyCode</code> (results in AnnotationException: AttributeOverride.column() should override all columns for now)</li>
  </ol>
  
  <p>Hibernate does not seem to really care too much what comes after the dot. I can change that to <code>amount.abcdef</code> and it will not throw an error, so I'm pretty much just guessing right now, how to override these column names.</p>
  
  <p>When <code>Amount</code> is not inside an <code>Embeddable</code> it works just fine with this declaration, even when used multiple times in the same entity.</p>
  
  <pre><code>    @Type(type = Amount.TYPE_DEF)
      @Columns(columns = {
          @Column(name = "amount"),
          @Column(name = "currencyCode")})
      private Amount amount;
  </code></pre>
  
  <p>Does somebody have an idea?
  All I could find to that topic was only related to Embeddables and not CompositeUserTypes inside Embeddables.</p>
  
  <p>I'm using hibernate-5.1.2-final.</p>