开发者

about jpa sequence generation

开发者 https://www.devze.com 2023-03-11 23:15 出处:网络
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

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
0

精彩评论

暂无评论...
验证码 换一张
取 消