title: How do I disable Hibernate foreign key constraint on a bidirectional association?
body: <p>I am trying to disable the foreign key constraint being generated on my bidirectional association.  I have managed to do this for all my unidirectional associations, but for some reason it is not working here.</p>
  
  <p>I do know about the bug with <em>ContraintMode.NO_CONSTRAINT</em> that was recently fixed in Hibernate 5.x, and I am running the latest Hibernate 5.2.6.</p>
  
  <p>My annotations presently look like this:</p>
  
  <pre><code>class Parent {
    @OneToMany(mappedBy="parent", cascade=CascadeType.ALL, orphanRemoval=true)
    @OrderColumn(name="childIndex")
    public List&lt;Child&gt; getChildren() {
      return children;
    }
  }
  
  class Child {
    @ManyToOne(optional=false)
    @JoinColumn(name="parent", foreignKey = @ForeignKey(value = ConstraintMode.NO_CONSTRAINT))
    public Parent getParent() {
      return parent;
    }
  }
  </code></pre>
  
  <p>But despite NO_CONSTRAINT, Hibernate is still creating the foreign key constraint on child.parent -> parent.id.</p>
  
  <p>Is there something additional I need to do to suppress the foreign key for the bidirectional case?</p>
  
  <p>Thanks!</p>