带有GenerationType.TABLE的JPA GeneratedValue会在jvm重新启动后执行大跳转 [英] JPA GeneratedValue with GenerationType.TABLE does a big jump after jvm restart

查看:91
本文介绍了带有GenerationType.TABLE的JPA GeneratedValue会在jvm重新启动后执行大跳转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我启动我的服务器并添加一个条目时,生成的ID将以1,2开头,等等。重新启动后,添加一个条目会生成一个像32,xxx这样的标识。另一个重新启动和添加条目会生成一个像65,xxx的id。

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.

以下是我用于我的ID的注释片段。

Here's a snippet of the annotation I'm using for my id. I'm using Hibernate 3.4.0.GA.

@Id
@GeneratedValue(strategy = GenerationType.TABLE)
private Long id;


推荐答案

你在这里使用什么版本的Hibernate?我见过一些关于最近版本的id代的问题(如 HHH-4228 HHH-4228 和另一个关于hi-值被错误地计算,我无法找回)已经在Hibernate 3.5.2中修复。你可以试试吗?

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?

如果不适用,如果使用 allocationSize = 1

If this doesn't apply, what happen if you use allocationSize=1?

这篇关于带有GenerationType.TABLE的JPA GeneratedValue会在jvm重新启动后执行大跳转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆