title: How to set foreign key contraint name generated by hibernate on a linking table?
body: <p>I want to let <code>hibernate</code> create sql base on the following mapping:</p>
  
  <pre><code>@Entity
  public class MyBaseEntity {
      @EmbeddedId
      private MyEmbeddable id;
  
      @ManyToMany
      @JoinTable(name = "mybaseentity_mymode", //sets the linking table name
      joinColumns = {
          @JoinColumn(name = "fk_param1", referencedColumnName = "param2"), //@Id param
          @JoinColumn(name = "fk_pram2", referencedColumnName = "param2")}, //@Id param
              foreignKey = @ForeignKey(name = "fk_myembeddable_id")) //the contraint name
      private Set&lt;MyModes&gt; modes;
  }
  
  @Embeddable
  public class MyEmbeddable {
      private String param1;
      private String param2;
  }
  
  @Entity
  public class MyMode {
      @Id
      private long id;
  
      private String code;
  }
  </code></pre>
  
  <p>Each <code>MyBaseEntity</code> can have multiple modes. And the same <code>MyMode</code> can be linked to multiple base entities.</p>
  
  <p>Question: how can I define the generated name of <code>CONSTRAINT</code> and <code>UNIQUE</code> inside the autogenerated linking table?</p>
  
  <p>So far I used <code>@JoinTable</code> and two <code>@JoinColumn</code> definitions to set the constraint of the <code>@EmbeddedId</code> reference. But the foreign key constraint name reference to <code>MyMode</code> entity is still autogenerated.</p>
  
  <p>Resulting sql so far with auto generated names:</p>
  
  <pre><code>CREATE TABLE public.mybaseentity_mymode
  (
    mybaseentity_param1 character varying(255) NOT NULL,
    mybaseentity_param2 character varying(255) NOT NULL,
    modes_id bigint NOT NULL,
    CONSTRAINT mybaseentity_mymode_pkey PRIMARY KEY (mybaseentity_param1, mybaseentity_param2, modes_id),
    CONSTRAINT fk9tr9k9gtbqcpvoxfv2hqop6ta FOREIGN KEY (modes_id)
        REFERENCES public.mymode (id) MATCH SIMPLE
        ON UPDATE NO ACTION ON DELETE NO ACTION,
    CONSTRAINT fk_myembeddable_id FOREIGN KEY (fk_param1, fk_param2)
        REFERENCES public.mybaseentity (param1, param2) MATCH SIMPLE
        ON UPDATE NO ACTION ON DELETE NO ACTION
  )
  </code></pre>