假设我有
@Entity
public class Car implements Serializable{
@Id private Long id = null;
@Index private Driver driver = null;
...
}
和
@Entity
public class Driver implements Serializable{
@Id private Long id = null;
...
}
如何在 Objectify 中通过司机实体的 id 过滤汽车实体?类似于 ofy().load().type(Car.class).filter("driver.id", someId).first().now();
提前致谢。
最佳答案
目前还不能。即使你可以,它几乎肯定会是一些尴尬的事情,比如 filter("driver.__key__", Key.create(Driver.class, someId))
。这已经进入了一个尚未探索的领域。除非您非常熟悉 GAE 和 Objectify,否则最好放弃 @Id
注释并像常规嵌入对象一样对待嵌入实体。 id
没有理由不能只是一个常规(索引)属性。
关于java - 按 Objectify 中嵌入实体的 ID 进行过滤,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32291891/