about jpa sequence generation
Hello every body I have used following code in my jpa project for working of sequence
开发者_如何转开发generation,its giving exception that pre-allocation size is not set correctly,but I have been set it correctly,interesting fact is its runing successfully and working correctly when I am trying to run it second time and so on.please tell me the problem why its not working first time. @Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator="studentgen")
@SequenceGenerator(name="studentgen", sequenceName="myseq", allocationSize=100)
private int id;
Are you sure you have the same sequence in your DB (sequenceName="myseq") ?
Also, you have set the allocated size to 100, which means you have to have the step size in your sequence to be 100 as well.
Example:
Create Sequence myseq start with 1 maxvalue 99999999 increment by 100
精彩评论