Java JPA allocationSize不使用PostgreSQL序列

Java JPA allocationSize不使用PostgreSQL序列,java,postgresql,jpa,Java,Postgresql,Jpa,Netbeans 8.0.2(标准模块) Eclipselink(JPA2.1)(默认) Glassfish 4.0(标准模块) PostgreSQL 9.4(在win7x64下) CustomerContact.class: @Id @SequenceGenerator(name="customerContactSequence", sequenceName="customer_contact_seq", allocationSize=356, initialValue=2345) @

Netbeans 8.0.2(标准模块)

Eclipselink(JPA2.1)(默认)

Glassfish 4.0(标准模块)

PostgreSQL 9.4(在win7x64下)

CustomerContact.class:

@Id
@SequenceGenerator(name="customerContactSequence", sequenceName="customer_contact_seq", allocationSize=356, initialValue=2345)    
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator="customerContactSequence")
private Long id;
JPA/PostgreSQL将id分配给初始值正确但分配大小不正确的行。Id增加1,而不是356。我试图从pgAdmin(值正确)和em.createNativeQuery(值正确)中选择nextval,但在em.persist id中选择错误。我追踪了日食,见附件


你说“值是正确的”是什么意思?你的意思是序列会增加365?当您使用allocationsize时,JPA实现将填充中间的步骤,从而减少数据库中的序列访问数。不确定Eclipselink做什么,Hibernate至少使用了HoLo算法:(搜索SEQ_GEN)是您自己创建的表,还是使用Eclipselink生成的表?如果是您自己创建的,您有责任确保序列增量与
SequenceGenerator
@eckes值中声明的
allocationSize
相同,但allocationSize不起作用。@CraigRinger表是由EclipseLink创建的。序列增量是正确的(在PostgreSQL中),序列在pgAdmin和eclipselink nativequery中工作,但是当eclipselink使用persist方法创建实体时,实体的ID没有正确的增量(参见上面的附件)