entry_id_seq
我们有一个存储过程,它为条目 id ( )生成数字。通过以下设置,代码生成的数字比直接用 SQL 调用的数字要大。
例如,以下代码为 id 生成一个数字“11195215652”。但是如果我运行select entry_id_seq.NEXTVAL nv from dual
,它会返回小得多的“32350910”。
@javax.persistence.SequenceGenerator(name = "seq",
sequenceName = "entry_id_seq")
public class SomeClassimplements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq")
@Column(name = "ID")
private Long id;
我尝试了下面的建议
@javax.persistence.SequenceGenerator(name = "seq",
sequenceName = "entry_id_seq", allocationSize = 1, initialValue= 1)
但它给了我以下错误:
Caused by: org.hibernate.HibernateException: increment size cannot be less than 1
at org.hibernate.id.enhanced.OptimizerFactory$LegacyHiLoAlgorithmOptimizer.<init>(OptimizerFactory.java:336)
at org.hibernate.id.SequenceHiLoGenerator.configure(SequenceHiLoGenerator.java:64)
at org.hibernate.id.factory.DefaultIdentifierGeneratorFactory.createIdentifierGenerator(DefaultIdentifierGeneratorFactory.java:110)