JPA Eclipselink getting wrong sequence number

风格不统一 提交于 2019-12-05 21:52:00

When you created the sequence you specified a size to increment by. For example this sequence increments by 1.

CREATE SEQUENCE supplier_seq
  MINVALUE 1
  MAXVALUE 999999999999999999999999999
  START WITH 1
  INCREMENT BY 1
  CACHE 20;

When using the SequenceGenerator annotation in JPA you can specify an allocation size.

@Id
@SequenceGenerator(name = "SEQ_RULES", sequenceName = "SEQUENZ_RULES",
    allocationSize=1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_RULES")
@Column(name = "SERIALNO")
protected Long serialno;

Make sure the allocation size and the increment match between JPA and the Sequence DDL.

Juan Rodriguez

Change allocationSize=1 by allocationSize=2, it is a Eclipselink bug.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!