Frage

I have following entity:

class Linf {
     @Id
     ObjectId id;
     @Reference
     Denied denied;
}

I want to find all Linfs that have Denied object with certain id. How can I do this? Will this query employ indexes? I want to avoid full scan if possible.

Thanx.

War es hilfreich?

Lösung 2

This works for me:

    Denied d2 = new Denied();
    d2.id = new ObjectId("52b4709f423d856472c34fa1");

    List list = datastore
            .createQuery(Linf.class)
            .field("denied")
            .equal(d2).asList();

Andere Tipps

If you don't have an index on "denied" it'll be a full collection scan either way but something like this should do it for you:

datastore.createQuery(Linf.class).field("denied").equal(new Key<Denied>(Denied.class, id)).fetch()
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top