gpt4 book ai didi

java - Migration play 2.4后,使用postgresdb已有序列生成Play-2.4 Entity的id

转载 作者:行者123 更新时间:2023-11-29 13:56:01 25 4
gpt4 key购买 nike

我们一直在使用 Play 2.3.9,现在我们正在迁移到 Play 2.4.1 当我使用旧版本的 Play 保存实体时有效,但使用新版本时不会生成 Id。

如果我使用,

@GeneratedValue(strategy = GenerationType.SEQUENCE)

它工作正常,但在使用时,

@Id
@GeneratedValue(strategy = GenerationType.AUTO)

在模型中低于异常

[error] p.c.s.n.PlayDefaultUpstreamHandler - Cannot invoke the action
javax.persistence.PersistenceException: ERROR executing DML bindLog[] error[ERROR: null value in column "id" violates not-null constraint\n Detail: Failing row contains (null, null, kumar, null, 9581672143, kumar@gmail.com, +j+b2lc5C7B48IGct2+L1jKBEIXhl0aOYy1BOnb85/Q=, iCZqST2EU4ECVaPwzGxr1hZ/b4Da34BI/C9xKCbpo78=, null, null, null, f, f, null, BLOOD_BANK_ADMIN, null, f, f, null, null, null, null, t, f, 2015-08-03 15:53:47.308, 2015-08-03 15:53:47.309, null, null, null, null, null, null, null, f, null).]
at com.avaje.ebeaninternal.server.persist.dml.DmlBeanPersister.execute(DmlBeanPersister.java:90) ~[avaje-ebeanorm-4.6.2.jar:na]
at com.avaje.ebeaninternal.server.persist.dml.DmlBeanPersister.insert(DmlBeanPersister.java:57) ~[avaje-ebeanorm-4.6.2.jar:na]
at com.avaje.ebeaninternal.server.persist.DefaultPersistExecute.executeInsertBean(DefaultPersistExecute.java:59) ~[avaje-ebeanorm-4.6.2.jar:na]
at com.avaje.ebeaninternal.server.core.PersistRequestBean.executeNow(PersistRequestBean.java:446) ~[avaje-ebeanorm-4.6.2.jar:na]
at com.avaje.ebeaninternal.server.core.PersistRequestBean.executeOrQueue(PersistRequestBean.java:480) ~[avaje-ebeanorm-4.6.2.jar:na]

有什么建议吗?

最佳答案

从ebean 4.0.5开始,id生成策略从IDENTITY变为GENERATOR。解决方法:Play Framework 2.4 Ebean Id Generation

关于java - Migration play 2.4后,使用postgresdb已有序列生成Play-2.4 Entity的id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31786344/

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