我的实体中有以下属性:
@OneToOne
@JoinColumn(unique = true)
@NotNull(message = ValidatorUtils.ERROR_NOT_NULL)
public User user;
当我刷新浏览器并尝试生成数据库迁移时,我得到以下堆栈跟踪:
[error] application -
! @6gmdbcgi0 - Internal server error, for (GET) [/] ->
play.api.UnexpectedException: Unexpected exception[NullPointerException: null]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:148) ~[play_2.10.jar:2.2.0]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:112) ~[play_2.10.jar:2.2.0]
at scala.Option.map(Option.scala:145) ~[scala-library.jar:na]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(ApplicationProvider.scala:112) ~[play_2.10.jar:2.2.0]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(ApplicationProvider.scala:110) ~[play_2.10.jar:2.2.0]
at scala.util.Success.flatMap(Try.scala:200) ~[scala-library.jar:na]
Caused by: java.lang.NullPointerException: null
at com.avaje.ebeaninternal.server.ddl.CreateTableVisitor.isDbColumnWritten(CreateTableVisitor.java:59) ~[avaje-ebeanorm.jar:na]
at com.avaje.ebeaninternal.server.ddl.CreateTableColumnVisitor.visitOneImported(CreateTableColumnVisitor.java:111) ~[avaje-ebeanorm.jar:na]
at com.avaje.ebeaninternal.server.ddl.VisitorUtil.visit(VisitorUtil.java:109) ~[avaje-ebeanorm.jar:na]
at com.avaje.ebeaninternal.server.ddl.VisitorUtil.visit(VisitorUtil.java:73) ~[avaje-ebeanorm.jar:na]
at com.avaje.ebeaninternal.server.ddl.VisitorUtil.visitBean(VisitorUtil.java:62) ~[avaje-ebeanorm.jar:na]
at com.avaje.ebeaninternal.server.ddl.VisitorUtil.visit(VisitorUtil.java:36) ~[avaje-ebeanorm.jar:na]
如果我删除 @JoinColumn 批注,我的架构会正确迁移。如何在没有此错误的情况下将列指定为唯一?谢谢。
编辑 01/09/2014:添加生成的 ddl
这是生成的 ddl :
我希望生成的 ddl 包含以下内容:
constraint uq_user_id unique (user_id)