Let's say I have
@Entity
public class Car implements Serializable{
@Id private Long id = null;
@Index private Driver driver = null;
...
}
and
@Entity
public class Driver implements Serializable{
@Id private Long id = null;
...
}
How can I filter a Car entity by the id of his driver entity in Objectify? Something like ofy().load().type(Car.class).filter("driver.id", someId).first().now();
Thanks in advance.
At present, you can't. And even if you could, it would almost certainly be something awkward like filter("driver.__key__", Key.create(Driver.class, someId))
. This is getting pretty far into unexplored territory. Unless you're super familiar with GAE and Objectify, you're best off dropping the @Id
annotation and treating embedded entities just like regular embedded objects. There's no reason why id
can't just be a regular (indexed) property.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.