title: JPA 2.1 / Hibernate 5.0 Foreignkey name in @JoinColumn is ignored when generating DDL
body: <p>I am migrating my project to Hibernate 5.0. We use a generated DDL for multiple reasons so the DDL should be exactly the same as it was before. I've got most of it working except for the <code>@ForeignKey</code> name in a <code>@JoinColumn</code> in a <code>@OneToMany</code> relationship</p>
  
  <p>I have a Child entity:</p>
  
  <pre><code>@Entity
  @Table(name = "CHILD", indexes = { @Index(columnList = "NAME", name = "IDX_CHILD_NAME") }, uniqueConstraints = { @UniqueConstraint(columnNames = "NAME", name = "UK_CHILD_NAME") })
  @SequenceGenerator(allocationSize = 1, name = "CHILD_ID_GENERATOR", sequenceName = "CHILD_ID_SEQ")
  public class Child {
      @Id
      @GeneratedValue(generator = "CHILD_ID_GENERATOR", strategy = SEQUENCE)
      @Column(name = "ID")
      private Long id;
  
      @Column(name = "NAME")
      private String name;
  
      @OneToMany()
      @JoinColumn(name = "CHILD_ID", foreignKey = @ForeignKey(name = "FK_CHILD_PET"))
      private List&lt;Pet&gt; pets;
  
  }
  </code></pre>
  
  <p>And a Pet entity:</p>
  
  <pre><code>@Entity
  @Table(name = "PET", indexes = { @Index(columnList = "NAME", name = "IDX_PET_NAME") }, uniqueConstraints = { @UniqueConstraint(columnNames = "NAME", name = "UK_PET_NAME") })
  @SequenceGenerator(allocationSize = 1, name = "PET_ID_GENERATOR", sequenceName = "PET_ID_SEQ")
  public class Pet {
      @Id
      @GeneratedValue(generator = "PET_ID_GENERATOR", strategy = SEQUENCE)
      @Column(name = "ID")
      private Long id;
  
      @Column(name = "NAME")
      private String name;
  
  
  
  }
  </code></pre>
  
  <p>But when I try to generate a DDL I get the following statement:</p>
  
  <pre><code>alter table PET add constraint FKaxwc707slbsrp6vgxyyydrvcy foreign key (CHILD_ID) references CHILD
  </code></pre>
  
  <p>When I change the annotations to include the deprecated ForeignKey of Hibernate like this</p>
  
  <pre><code>@OneToMany()
  @org.hibernate.annotations.ForeignKey(name = "FK_CHILD_PET")
  @JoinColumn(name = "CHILD_ID")
  private List&lt;Pet&gt; pets;
  </code></pre>
  
  <p>I do get the desired output</p>
  
  <pre><code>alter table PET add constraint FK_CHILD_PET foreign key (CHILD_ID) references CHILD
  </code></pre>
  
  <p>But I want to eliminate that deprecated Hibernate ForeignKey annotations.</p>
  
  <p>Any suggestions?</p>
  
  <p>I also included the above code in a sample project:
  <a href="https://github.com/vdmc/generate-ddl-example.git" rel="nofollow">https://github.com/vdmc/generate-ddl-example.git</a></p>