@Test public void testCreateRootQuery_Pagination() { RootResourceEntity<E1> resourceEntity = new RootResourceEntity<>(getAgEntity(E1.class), null); resourceEntity.setFetchLimit(10); resourceEntity.setFetchOffset(0); SelectContext<E1> c = new SelectContext<>(E1.class); c.setEntity(resourceEntity); SelectQuery<E1> q1 = queryAssembler.createRootQuery(c); assertEquals(10, q1.getPageSize(), "Pagination in the query for paginated request is expected"); assertEquals(0, q1.getFetchOffset()); assertEquals(0, q1.getFetchLimit()); resourceEntity.setFetchLimit(0); resourceEntity.setFetchOffset(0); resourceEntity.setSelect(null); SelectQuery<E1> q2 = queryAssembler.createRootQuery(c); assertEquals(0, q2.getPageSize()); assertEquals(0, q2.getFetchOffset()); assertEquals(0, q2.getFetchLimit()); resourceEntity.setFetchLimit(0); resourceEntity.setFetchOffset(5); SelectQuery<E1> q3 = queryAssembler.createRootQuery(c); assertEquals(0, q3.getPageSize()); assertEquals(0, q3.getFetchOffset()); assertEquals(0, q3.getFetchLimit()); }
public <T> SelectQuery<T> createRootQuery(SelectContext<T> context) { SelectQuery<T> query = context.getId() != null ? createRootIdQuery(context.getEntity(), context.getId()) : createQuery(context.getEntity()); if (context.getParent() != null) { query.andQualifier(CayenneUtil.parentQualifier(context.getParent(), cayenneEntityResolver)); } return query; }
CayenneQueryAssembler { public <T> SelectQuery<T> createRootQuery(SelectContext<T> context) { SelectQuery<T> query = context.getId() != null ? createRootIdQuery(context.getEntity(), context.getId()) : createQuery(context.getEntity()); if (context.getParent() != null) { query.andQualifier(CayenneUtil.parentQualifier(context.getParent(), cayenneEntityResolver)); } return query; } }
CayenneQueryAssembler { public <T> SelectQuery<T> createRootQuery(SelectContext<T> context) { SelectQuery<T> query = context.getId() != null ? createRootIdQuery(context.getEntity(), context.getId()) : createQuery(context.getEntity()); if (context.getParent() != null) { query.andQualifier(CayenneUtil.parentQualifier(context.getParent(), cayenneEntityResolver)); } return query; } CayenneQueryAssembler(EntityResolver cayenneEntityResolver); }
CayenneQueryAssembler { public <T> SelectQuery<T> createRootQuery(SelectContext<T> context) { SelectQuery<T> query = context.getId() != null ? createRootIdQuery(context.getEntity(), context.getId()) : createQuery(context.getEntity()); if (context.getParent() != null) { query.andQualifier(CayenneUtil.parentQualifier(context.getParent(), cayenneEntityResolver)); } return query; } CayenneQueryAssembler(EntityResolver cayenneEntityResolver); SelectQuery<T> createRootQuery(SelectContext<T> context); SelectQuery<T> createQueryWithParentQualifier(NestedResourceEntity<T> entity); SelectQuery<T> createQueryWithParentIdsQualifier(NestedResourceEntity<T> entity, Iterator<P> parentData); SelectQuery<T> createRootIdQuery(ResourceEntity<T> entity, AgObjectId rootId); SelectQuery<T> createQuery(ResourceEntity<T> entity); Expression buildIdQualifer(AgEntity<?> entity, AgObjectId id); }
CayenneQueryAssembler { public <T> SelectQuery<T> createRootQuery(SelectContext<T> context) { SelectQuery<T> query = context.getId() != null ? createRootIdQuery(context.getEntity(), context.getId()) : createQuery(context.getEntity()); if (context.getParent() != null) { query.andQualifier(CayenneUtil.parentQualifier(context.getParent(), cayenneEntityResolver)); } return query; } CayenneQueryAssembler(EntityResolver cayenneEntityResolver); SelectQuery<T> createRootQuery(SelectContext<T> context); SelectQuery<T> createQueryWithParentQualifier(NestedResourceEntity<T> entity); SelectQuery<T> createQueryWithParentIdsQualifier(NestedResourceEntity<T> entity, Iterator<P> parentData); SelectQuery<T> createRootIdQuery(ResourceEntity<T> entity, AgObjectId rootId); SelectQuery<T> createQuery(ResourceEntity<T> entity); Expression buildIdQualifer(AgEntity<?> entity, AgObjectId id);  }