title: JPA @ForeignKey(value = ConstraintMode.NO_CONSTRAINT) not working with @ManyToMany
body: <p>I have two entities with ManyToMany Relationship. Goal here is to create schema when application start with <em><strong>no foreign key</strong></em></p>
  <p><strong>1). Job.java</strong></p>
  <pre><code>package com.govjobportalbackend.entity;
  
  import java.util.List;
  
  import javax.persistence.Column;
  import javax.persistence.ConstraintMode;
  import javax.persistence.Entity;
  import javax.persistence.ForeignKey;
  import javax.persistence.JoinColumn;
  import javax.persistence.JoinTable;
  import javax.persistence.ManyToMany;
  import javax.persistence.ManyToOne;
  import javax.persistence.Table;
  
  @Entity
  @Table(name = &quot;job&quot;)
  public class Job extends BasicEntity {
  
      @Column(name = &quot;icon&quot;)
      private String icon;
  
      @ManyToMany
      @JoinTable(
              name=&quot;job_city&quot;,
              joinColumns = @JoinColumn(name = &quot;job_id&quot;),
              inverseJoinColumns = @JoinColumn(name = &quot;city_id&quot;),
              foreignKey = @ForeignKey(value = ConstraintMode.NO_CONSTRAINT),
              inverseForeignKey = @ForeignKey(value = ConstraintMode.NO_CONSTRAINT)
      )
      private List&lt;City&gt; cities;
  
      public String getIcon() {
          return icon;
      }
  
      public void setIcon(String icon) {
          this.icon = icon;
      }
  
      public List&lt;City&gt; getCities() {
          return cities;
      }
  
      public void setCities(List&lt;City&gt; cities) {
          this.cities = cities;
      }
  
  }
  </code></pre>
  <p><strong>2). City.java</strong></p>
  <pre><code>package com.govjobportalbackend.entity;
  
  import java.util.List;
  
  import javax.persistence.DiscriminatorValue;
  import javax.persistence.Entity;
  import javax.persistence.ManyToMany;
  
  @Entity
  @DiscriminatorValue(value = &quot;city&quot;)
  public class City extends JobMetadata {
  
      @ManyToMany(mappedBy = &quot;cities&quot;)
      private List&lt;Job&gt; jobs;
  
      @Override
      public List&lt;Job&gt; getJobs() {
          return jobs;
      }
  
      @Override
      public void setJobs(List&lt;Job&gt; jobs) {
          this.jobs = jobs;
      }
  }
  </code></pre>
  <p>Below property is set in <em>application.properties</em> file</p>
  <pre><code>spring.jpa.hibernate.ddl-auto=update
  </code></pre>
  <p>When run the application, it is logging below SQLs in logs and is creating two foreign keys</p>
  <pre><code>Hibernate: create table job (id int4 not null, name varchar(255), icon varchar(255), primary key (id))
  Hibernate: create table job_city (job_id int4 not null, city_id int4 not null)
  Hibernate: create table job_metadata (type varchar(31) not null, id int4 not null, name varchar(255), primary key (id))
  Hibernate: alter table if exists job_city add constraint FKiksm0d31mc3osxut4ciaf4uof foreign key (job_id) references job
  Hibernate: alter table if exists job_city add constraint FKknw4pf63xt1tvnqrmrjrm5hqq foreign key (city_id) references job_metadata
  </code></pre>
  <p>If I annotate as per below in <em><strong>City.java</strong></em> then it works as expected but as per my &quot;little&quot; research, this bug is fixed in hibernate (so mapped entity is not required to be annotated with depreciated annotation), or may be I am wrong.</p>
  <pre><code>@ManyToMany(mappedBy = &quot;cities&quot;)
  @org.hibernate.annotations.ForeignKey(name = &quot;none&quot;)
  private List&lt;Job&gt; jobs;
  </code></pre>
  <p>Environment I am using is below;</p>
  <ul>
  <li>Java 11</li>
  <li>Hibernate 5.4.28.Final (spring-boot-starter-web)</li>
  </ul>