gpt4 book ai didi

ejb-3.0 - Postgres + EJB3 预分配大小错误

转载 作者:行者123 更新时间:2023-12-04 05:56:18 24 4
gpt4 key购买 nike

我在 postgres 和 jpa 中遇到序列问题

Caused by: javax.persistence.EntityExistsException:
Exception Description: The sequence named [shp_users_seq] is setup incorrectly. Its increment does not match its pre-allocation size.
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.persist(EntityManagerImpl.java:443)
at com.sun.enterprise.container.common.impl.EntityManagerWrapper.persist(EntityManagerWrapper.java:269)
at base.data.provider.beans.session.DAOImpl.createUser(DAOImpl.java:18)

最佳答案

规则是:序列的增量大小是jpa中allocationSize的值:
我有这个设置:这是错误的:

@SequenceGenerator(name = "User_Seq_Gen", 
sequenceName = "shp_users_seq", allocationSize=999)

据此更正:
@SequenceGenerator(name = "User_Seq_Gen", 
sequenceName = "shp_users_seq" ,allocationSize=1)

因为序列的增量大小为 1:
 shopper=> \d shp_users_seq;
Sequence "public.shp_users_seq"
Column | Type | Value
---------------+---------+---------------------
sequence_name | name | shp_users_seq
last_value | bigint | 1
start_value | bigint | 1
increment_by | bigint | 1
max_value | bigint | 9223372036854775807
min_value | bigint | 1
cache_value | bigint | 1
log_cnt | bigint | 0
is_cycled | boolean | f
is_called | boolean | t

关于ejb-3.0 - Postgres + EJB3 预分配大小错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9477999/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com