我是 Ebeans / Play 2.0.4 的新手,我正在尝试对以下内容进行建模:
One question has many answers
所以我的课程看起来像这样:
问题模型:
package models;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.OneToMany;
import play.db.ebean.Model;
@Entity
public class Question extends Model {
@OneToMany(cascade=CascadeType.ALL)
public List<Answer> answers = new ArrayList<Answer>();
}
答案型号:
package models;
import javax.persistence.Entity;
import javax.persistence.Id;
import play.db.ebean.Model;
@Entity
public class Answer extends Model {
@Id
public Integer id;
}
但是,这给了我以下错误:
java.lang.RuntimeException: No join columns
我究竟做错了什么?在生成的 DDL 中,我需要“更新级联”- CascadeType.ALL 是正确的类型吗?谢谢 :-)