title: hibernate collection - invalid column index
body: <p>I have created a parent and child class in hibernate and JPA. When I attempt to persist the class I get a SQL exception stating "invalid column index".</p>
  
  <p>This is the parent class:</p>
  
  <pre><code>@Entity
  @Table(name = "vnd_base_file_format")
  public class VendorBaseFileFormat implements Serializable {
      private static final long serialVersionUID = 1L;
  
      @Id
      @Column(name = "base_file_format_id")
      private int baseFileFormatId;
  
      @Column(name = "vendor_id")
      private int vendorId;
  
      @Column(name = "format_name")
      private String formatName;
  
      @Column(name = "enabled")
      private boolean enabled;
  
      @Column(name = "month_year_format")
      private String monthYearFormat;
  
      @OneToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
      @JoinColumn(name="base_file_format_id", nullable=false)
      @OrderBy("index")
      private List&lt;VendorBaseFileDimension&gt; dimensions;
  </code></pre>
  
  <p>This is the child class:</p>
  
  <pre><code>@Entity
  @Table(name = "vnd_base_file_format_dim")
  public class VendorBaseFileDimension implements Serializable {
      private static final long serialVersionUID = 1L;
  
      @Id
      @Column(name = "dimension_id")
      private int dimensionId;
  
      @Column(name = "alternate_name")
      private String alternateName;
  
      @Column(name = "dimension_index")
      private int index;
  
      @Id
      @ManyToOne
      @JoinColumn(name="base_file_format_id", nullable=false, insertable=false)
      private VendorBaseFileFormat format;
  </code></pre>
  
  <p>I simply create the parent class and add one child class to it.  When I call entityManager.persist I get the following message:</p>
  
  <pre><code>Hibernate: insert into vnd_base_file_format (enabled, format_name, month_year_format, vendor_id, base_file_format_id) values (?, ?, ?, ?, ?)
  Hibernate: insert into vnd_base_file_format_dim (alternate_name, dimension_index, base_file_format_id, dimension_id) values (?, ?, ?, ?)
  [21:53:01.159] WARN  JDBCExceptionReporter - SQL Error: 17003, SQLState: 99999
  [21:53:01.159] ERROR JDBCExceptionReporter - Invalid column index
  </code></pre>
  
  <p>Any help would be appreciated.  I have tried a few things like setting insertable to false, but no luck.  I did see one question out there that mentioned there might be a problem with composite keys.  Do I really have to create a unique sequence column on the child when it is only going to exist as part of the parent?</p>