我已将休眠配置为使用 oracle 序列。使用 cache=20,increment=1 创建序列。
一切正常,休眠持久实体。id值很奇怪:50,51....76,201,202...209,1008,1009,5129,5130 ....
如果我要求序列值(从 dual 中选择 hibernate_sequence.nextval),我得到的值类似于 2,3,4 ....
如果我打开休眠 sql 调试,有时会调用“select hibernate_sequence.nextval from dual”但是休眠分配给 ID 的数字不会按顺序传递!
@Id
@Column(name = "ID", insertable = false, updatable = false)
@SequenceGenerator(name = "SequenceIdGenerator", sequenceName = "HIBERNATE_SEQUENCE")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SequenceIdGenerator")
private Long id;