[jboss-user] [EJB 3.0] - Re: generating a Primary Key using a Sequence in JPA

ashusri000 do-not-reply at jboss.com
Tue Jun 26 03:57:05 EDT 2007


CORRECTION in above Post :


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


public class Tab1 implements Serializable {
@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE, 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 .


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4057579#4057579

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4057579



More information about the jboss-user mailing list