0 Replies Latest reply on Jun 26, 2007 2:47 AM by ashutosh sri

    generating a Primary Key using a Sequence in JPA

    ashutosh sri Newbie

      Hi All ,
      I have a simple POJO where I want to generate the Primary key value incremented by 1 each time a new row gets inserted , using a sequence . Here is the sample
      code:


      public class Tab1 implements Serializable {
      @Id
      @GeneratedValue(strategy=GenerationType.TABLE, generator = "tabGen")
      @SequenceGenerator(name="tabGen" , allocationSize=1)
      @Column(name="ID")
      private long id;


      But the problem with this is that it increments the value by 2 and not by 1 . Please can anybody help me out .