use of org.apache.cayenne.map.EntityResolver in project cayenne by apache.
the class SelectQueryIT method testRouteQueryWithPrefetchesPrefetchExpressionPath.
/**
* Test prefetching with qualifier on the root query being the path to the
* prefetch.
*/
@Test
public void testRouteQueryWithPrefetchesPrefetchExpressionPath() {
// find the painting not matching the artist (this is the case where
// such prefetch
// at least makes sense)
Expression exp = ExpressionFactory.noMatchExp("toArtist", new Object());
SelectQuery<Painting> q = new SelectQuery<>(Painting.class, exp);
q.addPrefetch("toArtist");
// test how prefetches are resolved in this case - this was a stumbling
// block for
// a while
EntityResolver resolver = context.getEntityResolver();
MockQueryRouter router = new MockQueryRouter();
q.route(router, resolver, null);
assertEquals(2, router.getQueryCount());
}
use of org.apache.cayenne.map.EntityResolver in project cayenne by apache.
the class LifecycleCallbackEventHandlerTest method testDefaultListeners.
@Test
public void testDefaultListeners() {
LifecycleCallbackEventHandler map = new LifecycleCallbackEventHandler(new EntityResolver());
L1 l1 = new L1();
map.addDefaultListener(l1, "callback");
C1 c1 = new C1();
c1.setObjectId(new ObjectId("bogus"));
assertEquals(0, l1.entities.size());
map.performCallbacks(c1);
assertEquals(1, l1.entities.size());
assertTrue(l1.entities.contains(c1));
}
use of org.apache.cayenne.map.EntityResolver in project cayenne by apache.
the class LifecycleCallbackRegistryTest method createRegistry.
@Before
public void createRegistry() {
EntityResolver entityResolver = mock(EntityResolver.class);
registry = new LifecycleCallbackRegistry(entityResolver);
for (LifecycleEvent event : LifecycleEvent.values()) {
assertEquals(0, registry.getHandler(event).defaultListenersSize());
assertEquals(0, registry.getHandler(event).listenersSize());
}
}
use of org.apache.cayenne.map.EntityResolver in project cayenne by apache.
the class EJBQLQueryIT method testUniqueKeyEntity.
@Test
public void testUniqueKeyEntity() {
// insertValue();
EntityResolver resolver = runtime.getDataDomain().getEntityResolver();
String ejbql = "select a FROM Artist a";
EJBQLQuery q1 = new EJBQLQuery(ejbql);
q1.setCacheStrategy(QueryCacheStrategy.LOCAL_CACHE);
EJBQLQuery q2 = new EJBQLQuery(ejbql);
q2.setCacheStrategy(QueryCacheStrategy.LOCAL_CACHE);
assertEquals(q1.getMetaData(resolver).getCacheKey(), q2.getMetaData(resolver).getCacheKey());
}
use of org.apache.cayenne.map.EntityResolver in project cayenne by apache.
the class EJBQLQueryIT method testGetMetadata.
@Test
public void testGetMetadata() {
EntityResolver resolver = runtime.getDataDomain().getEntityResolver();
String ejbql = "select a FROM Artist a";
EJBQLQuery query = new EJBQLQuery(ejbql);
QueryMetadata md = query.getMetaData(resolver);
assertNotNull(md);
assertNotNull(md.getClassDescriptor());
assertSame(resolver.getClassDescriptor("Artist"), md.getClassDescriptor());
assertNotNull(md.getObjEntity());
assertSame(resolver.getObjEntity("Artist"), md.getObjEntity());
assertFalse(md.isFetchingDataRows());
assertTrue(md.isRefreshingObjects());
assertEquals(QueryCacheStrategy.NO_CACHE, md.getCacheStrategy());
}
Aggregations