按 Objectify 中嵌入实体的 ID 过滤

Filter by the id of an embedded entity in Objectify

假设我有

@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 没有理由不能只是常规(索引)属性.