我们一直在使用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]
有什么建议吗?
答案 0 :(得分:0)
自ebean 4.0.5起,id genration策略已从IDENTITY变为GENERATOR。 解决方法:Play Framework 2.4 Ebean Id Generation