【发布时间】:2013-12-14 04:59:08
【问题描述】:
我有一个看起来像这样的Entity:
@Entity
public class Relationship
{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Key key;
@Basic
private UUID from;
@Basic
private UUID to;
}
现在我可以像这样在这里有任意级别的间接:
final Relationship r0 = new Relationship(a,b);
final Relationship r1 = new Relationship(b,c);
final Relationship r2 = new Relationship(c,d);
final Relationship rN = new Relationship(d,e);
现在我想尽可能有效地找出答案a 给我回e 其中rN 是N 级别深。
如果我写的是普通的SQL,我会做类似下面的伪代码:
SELECT r.to
FROM relationship r
WHERE r.from = 'a' AND
r.to NOT IN ( SELECT r.from FROM relationship r)
我在网上唯一能找到的就是将List 作为参数传递给Criteria.Builder.In 的引用,但我没有列表,我需要使用子选择作为列表吗?
这也是在 Google App Engine 中使用 Datastore,并且它通过 JPA 2 支持的某些内容受到限制。
我是否必须求助于低级别的Datastore API?
【问题讨论】:
标签: google-app-engine jpa google-cloud-datastore jpa-2.0