use of org.mongodb.morphia.query.TestQuery.ContainsPic in project morphia by mongodb.
the class TestQueriesOnReferences method testQueryOverReference.
@Test
public void testQueryOverReference() throws Exception {
final ContainsPic cpk = new ContainsPic();
final Pic p = new Pic();
getDs().save(p);
cpk.setPic(p);
getDs().save(cpk);
final Query<ContainsPic> query = getDs().find(ContainsPic.class);
final ContainsPic object = query.field("pic").equal(p).get();
Assert.assertNotNull(object);
}
use of org.mongodb.morphia.query.TestQuery.ContainsPic 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());
}
Aggregations