title: how to implement auto increment id field per table with Hibernate and postgresql for one to many relationships
body: <p>I have 4 entities one-to-many Message entity:</p>
  
  <pre><code>@Entity
  @Table(name = "Messages")
  public class Message {
  ...
      @ManyToOne(cascade = CascadeType.ALL)
      @JoinColumn(name = "messagesounds_id")
      private Sound sound;
  
      @ManyToOne(cascade = CascadeType.ALL)
      @JoinColumn(name = "messagevibrations_id")
      private Vibration vibration;
  
      @ManyToOne(cascade = CascadeType.ALL)
      @JoinColumn(name = "messagecolors_id")
      private Color color;
  
      @ManyToOne(cascade = CascadeType.ALL)
      @JoinColumn(name = "messageplatforms_id")
      private Platform platform;
  ...
  }
  </code></pre>
  
  <p>whereas other 4 entities look like this:</p>
  
  <pre><code>@Entity
  @Table( name = "MessageSounds"  , uniqueConstraints=@UniqueConstraint(columnNames = {"name"}))
  public class Sound {
      @Id
      @GeneratedValue(strategy=GenerationType.AUTO)
      private int id;
  
      @OneToMany(cascade={CascadeType.ALL})
      @JoinColumn(name="messagesounds_id")
      private Set&lt;Message&gt; message;
  ...
  }
  </code></pre>
  
  <p>I can successfully create the first message record referenced to those first records of the 4 referenced tables. But the message table in postgresql db looks like this:</p>
  
  <pre><code> id |...| messagesounds_id | messagevibrations_id | messagecolors_id | messageplatforms_id |
   1  |...| 2 | 3 | 4 | 5 |
  </code></pre>
  
  <p>I want to let every primary key of the 4 referenced tables be auto incremented, so that the first record of message table should look like this:</p>
  
  <pre><code> id |...| messagesounds_id | messagevibrations_id | messagecolors_id | messageplatforms_id |
   1  |...| 1 | 1 | 1 | 1 |
  </code></pre>
  
  <p>How to achieve this using annotations? </p>