Search in sources :

Example 1 with PicWithObjectId

use of org.mongodb.morphia.query.TestQuery.PicWithObjectId in project morphia by mongodb.

the class TestQueriesOnReferences method testQueryOverLazyReference.

@Test
public void testQueryOverLazyReference() throws Exception {
    final ContainsPic cpk = new ContainsPic();
    final Pic p = new Pic();
    getDs().save(p);
    final PicWithObjectId withObjectId = new PicWithObjectId();
    getDs().save(withObjectId);
    cpk.setLazyPic(p);
    cpk.setLazyObjectIdPic(withObjectId);
    getDs().save(cpk);
    Query<ContainsPic> query = getDs().find(ContainsPic.class);
    Assert.assertNotNull(query.field("lazyPic").equal(p).get());
    query = getDs().find(ContainsPic.class);
    Assert.assertNotNull(query.field("lazyObjectIdPic").equal(withObjectId).get());
}
Also used : ContainsPic(org.mongodb.morphia.query.TestQuery.ContainsPic) Pic(org.mongodb.morphia.query.TestQuery.Pic) ContainsPic(org.mongodb.morphia.query.TestQuery.ContainsPic) PicWithObjectId(org.mongodb.morphia.query.TestQuery.PicWithObjectId) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 ContainsPic (org.mongodb.morphia.query.TestQuery.ContainsPic)1 Pic (org.mongodb.morphia.query.TestQuery.Pic)1 PicWithObjectId (org.mongodb.morphia.query.TestQuery.PicWithObjectId)1