use of dev.morphia.test.query.TestLegacyQuery.PicWithObjectId in project morphia by mongodb.
the class TestQueriesOnReferences method testQueryOverLazyReference.
@Test
public void testQueryOverLazyReference() {
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);
assertNotNull(query.filter(eq("lazyPic", p)).iterator(new FindOptions().limit(1)).tryNext());
query = getDs().find(ContainsPic.class);
assertNotNull(query.filter(eq("lazyObjectIdPic", withObjectId)).iterator(new FindOptions().limit(1)).tryNext());
}
Aggregations