JPA GeneratedValue with GenerationType.TABLE does a big jump after jvm restart
When I start my server and add an entry, the generated id will start with 1, 2, so on and so forth. After a restart, adding an entry would generate an id like 32,xxx. Another restart and adding of entry would generate an id like 65,xxx.
I don't know why this is happening.
Here's a snippet of the annota开发者_开发问答tion I'm using for my id. I'm using Hibernate 3.4.0.GA.
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
private Long id;
What version of Hibernate are you using here? I've seen some issues about id generation with recent versions (like HHH-4228, HHH-4228 and another one about the hi-value being wrongly calculated that I can't find back) that have been fixed in Hibernate 3.5.2. Can you give it a try?
If this doesn't apply, what happen if you use allocationSize=1
?
精彩评论