0
時,我有以下四種模式:播放2.2.2 Ebean - 錯誤獲取豆描述查詢一對多
兼容性:
@Entity
public class Compatibility extends Model {
@Id
public long id;
@ManyToOne
public Attribute attr1;
@ManyToOne
public Attribute attr2;
public static Finder<Long, Compatibility> find = new Finder<Long, Compatibility>(
Long.class, Compatibility.class);
}
屬性:
@Entity
public class Attribute extends Model {
@Id
public long id;
public String userId;
@ManyToOne
public Parameter parameter;
public static Finder<Long, Attribute> find = new Finder<Long, Attribute>(
Long.class, Attribute.class);
}
參數:
@Entity
public class Parameter extends Model {
@Id
public long id;
@ManyToOne
public Problem problem;
public List<Attribute> attributes = new ArrayList<Attribute>();
public static Finder<Long, Parameter> find = new Finder<Long, Parameter>(
Long.class, Parameter.class);
}
問題:
@Entity
public class Problem extends Model {
@Id
public long id;
@OneToMany(cascade = CascadeType.ALL)
public List<Parameter> parameters = new ArrayList<Parameter>();
public static Finder<Long, Problem> find = new Finder<Long, Problem>(
Long.class, Problem.class);
}
使用Ebean,我試圖篩選,這取決於他們的問題屬於使用該Java代碼的所有兼容性:
List<Compatibility> cs = Ebean.find(Compatibility.class)
.fetch("attribute").fetch("parameter").fetch("problem").where()
.eq("problem.id", problemId).findList();
然而,我造成此錯誤:
[RuntimeException: Error getting BeanDescriptor for path problem from models.Compatibility]
我的猜測是跨幾個表的映射不起作用。有沒有任何我可以做到這一點?手動查詢也許?