title: JPA association without foreign key
body: <p>Is it possible to set up a ManyToOne association without JPA creating a foreign key in the database?</p>
  
  <p>The tables are owned by another system and are populated asynchronously. Thus we can't have a FK in the database. There's still, almost always, eventually a relation.</p>
  
  <pre><code>@ManyToOne(fetch = FetchType.LAZY)
  @JoinColumns({
          @JoinColumn(name="`Order Type`", referencedColumnName = "`Order Type`", insertable = false, updatable = false),
          @JoinColumn(name="`Order No`", referencedColumnName = "`No`", insertable = false, updatable = false)
  }, foreignKey = @javax.persistence.ForeignKey(value = ConstraintMode.NO_CONSTRAINT))
  private OrderHeader orderHeader;
  </code></pre>
  
  <p>The problem is that JPA SchemaUpdate tries to add a FK even though ConstraintMode.NO_CONSTRAINT</p>
  
  <blockquote>
    <blockquote>
      <p>[error] o.h.t.h.SchemaUpdate - Cannot add foreign key constraint</p>
    </blockquote>
  </blockquote>
  
  <p>and we could ignore that if it didn't make the rest of the statements fail</p>
  
  <blockquote>
    <blockquote>
      <p>[error] o.h.t.h.SchemaUpdate - No operations allowed after statement closed.</p>
    </blockquote>
  </blockquote>
  
  <p>We're on hibernate-entitymanager 4.3.7.Final and JPA 2.1.</p>