【发布时间】:2014-09-21 14:20:32
【问题描述】:
我有以下四种型号:
兼容性:
@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]
我的猜测是跨多个表的映射不起作用。我有任何方法可以完成这项工作吗?也许是手动查询?
【问题讨论】:
标签: java postgresql playframework ebean