title: Hibernate 4 and Postgres : How to create a sequence per table?
body: <p>I use Hibernate 4 to use mapping to a Postgres database. Before doing mapping i create first java entities. And then, i use a java class to generate sql script from my entities. Here is my entities : </p>
  
  <p>User entity</p>
  
  <pre><code>@Entity
  @Table(name="myusers")
  public class User {
  
  
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private int id;
  
      @Column(name="fistname")
      private String firstName;
  
      @Column(name="lastName")
      private String lastName;
  ....
  }
  </code></pre>
  
  <p>Project entity</p>
  
  <pre><code>@Entity
  @Table(name="projects")
  public class Project {
  
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private int id;
  
      @Column(name="title")
      private String title;
  
      @Column(name="description")
      private String description;
  ..
  }
  </code></pre>
  
  <p>I've noticed that <code>@GeneratedValue(strategy = GenerationType.AUTO)</code> produces the same sequence for table myusers and projects. If i create the first record on myusers table the id will have "1" as value and then when i create the first record in table projects, this record will have id =2. They use both the same sequence. 
  I want to know how i cannot modify my entities to specify to Hibernate to create a sequence for each table.</p>