@Test public void testEmptyScrollableResultSet() throws Exception { Iterator<?> iterator = scrollableResultSetLayer.getElements(null, 0, 0); Assert.assertFalse(iterator.hasNext()); }
public Iterator<?> getElements(Filter filter, int offset, int maxResultSize) throws LayerException { try { Session session = getSessionFactory().getCurrentSession(); Criteria criteria = session.createCriteria(getFeatureInfo().getDataSourceName()); if (filter != null) { if (filter != Filter.INCLUDE) { CriteriaVisitor visitor = new CriteriaVisitor((HibernateFeatureModel) featureModel, dateFormat); Criterion c = (Criterion) filter.accept(visitor, criteria); if (c != null) { criteria.add(c); } } } if (getFeatureInfo().getSortAttributeName() != null) { if (SortType.ASC.equals(getFeatureInfo().getSortType())) { criteria.addOrder(Order.asc(getFeatureInfo().getSortAttributeName())); } else { criteria.addOrder(Order.desc(getFeatureInfo().getSortAttributeName())); } } criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); if (isScrollableResultSet()) { return (Iterator<?>) new ScrollIterator(criteria.scroll()); } else { List<?> list = criteria.list(); return list.iterator(); } } catch (HibernateException he) { throw new HibernateLayerException(he, ExceptionCode.HIBERNATE_LOAD_FILTER_FAIL, getFeatureInfo() .getDataSourceName(), filter.toString()); } }
HibernateLayer extends HibernateLayerUtil implements VectorLayer, VectorLayerAssociationSupport,
		VectorLayerLazyFeatureConversionSupport { public Iterator<?> getElements(Filter filter, int offset, int maxResultSize) throws LayerException { try { Session session = getSessionFactory().getCurrentSession(); Criteria criteria = session.createCriteria(getFeatureInfo().getDataSourceName()); if (filter != null) { if (filter != Filter.INCLUDE) { CriteriaVisitor visitor = new CriteriaVisitor((HibernateFeatureModel) featureModel, dateFormat); Criterion c = (Criterion) filter.accept(visitor, criteria); if (c != null) { criteria.add(c); } } } if (getFeatureInfo().getSortAttributeName() != null) { if (SortType.ASC.equals(getFeatureInfo().getSortType())) { criteria.addOrder(Order.asc(getFeatureInfo().getSortAttributeName())); } else { criteria.addOrder(Order.desc(getFeatureInfo().getSortAttributeName())); } } criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); if (isScrollableResultSet()) { return (Iterator<?>) new ScrollIterator(criteria.scroll()); } else { List<?> list = criteria.list(); return list.iterator(); } } catch (HibernateException he) { throw new HibernateLayerException(he, ExceptionCode.HIBERNATE_LOAD_FILTER_FAIL, getFeatureInfo() .getDataSourceName(), filter.toString()); } } }
HibernateLayer extends HibernateLayerUtil implements VectorLayer, VectorLayerAssociationSupport,
		VectorLayerLazyFeatureConversionSupport { public Iterator<?> getElements(Filter filter, int offset, int maxResultSize) throws LayerException { try { Session session = getSessionFactory().getCurrentSession(); Criteria criteria = session.createCriteria(getFeatureInfo().getDataSourceName()); if (filter != null) { if (filter != Filter.INCLUDE) { CriteriaVisitor visitor = new CriteriaVisitor((HibernateFeatureModel) featureModel, dateFormat); Criterion c = (Criterion) filter.accept(visitor, criteria); if (c != null) { criteria.add(c); } } } if (getFeatureInfo().getSortAttributeName() != null) { if (SortType.ASC.equals(getFeatureInfo().getSortType())) { criteria.addOrder(Order.asc(getFeatureInfo().getSortAttributeName())); } else { criteria.addOrder(Order.desc(getFeatureInfo().getSortAttributeName())); } } criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); if (isScrollableResultSet()) { return (Iterator<?>) new ScrollIterator(criteria.scroll()); } else { List<?> list = criteria.list(); return list.iterator(); } } catch (HibernateException he) { throw new HibernateLayerException(he, ExceptionCode.HIBERNATE_LOAD_FILTER_FAIL, getFeatureInfo() .getDataSourceName(), filter.toString()); } }  }
HibernateLayer extends HibernateLayerUtil implements VectorLayer, VectorLayerAssociationSupport,
		VectorLayerLazyFeatureConversionSupport { public Iterator<?> getElements(Filter filter, int offset, int maxResultSize) throws LayerException { try { Session session = getSessionFactory().getCurrentSession(); Criteria criteria = session.createCriteria(getFeatureInfo().getDataSourceName()); if (filter != null) { if (filter != Filter.INCLUDE) { CriteriaVisitor visitor = new CriteriaVisitor((HibernateFeatureModel) featureModel, dateFormat); Criterion c = (Criterion) filter.accept(visitor, criteria); if (c != null) { criteria.add(c); } } } if (getFeatureInfo().getSortAttributeName() != null) { if (SortType.ASC.equals(getFeatureInfo().getSortType())) { criteria.addOrder(Order.asc(getFeatureInfo().getSortAttributeName())); } else { criteria.addOrder(Order.desc(getFeatureInfo().getSortAttributeName())); } } criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); if (isScrollableResultSet()) { return (Iterator<?>) new ScrollIterator(criteria.scroll()); } else { List<?> list = criteria.list(); return list.iterator(); } } catch (HibernateException he) { throw new HibernateLayerException(he, ExceptionCode.HIBERNATE_LOAD_FILTER_FAIL, getFeatureInfo() .getDataSourceName(), filter.toString()); } }  @Override String getId(); @Api void setId(String id); @Override CoordinateReferenceSystem getCrs(); @Override FeatureModel getFeatureModel(); @Override boolean useLazyFeatureConversion(); @Api void setUseLazyFeatureConversion(boolean useLazyFeatureConversion); @Api @Override void setLayerInfo(VectorLayerInfo layerInfo); @Override boolean isCreateCapable(); @Override boolean isUpdateCapable(); @Override boolean isDeleteCapable(); @Api void setFeatureModel(FeatureModel featureModel); @Api void setSessionFactory(SessionFactory sessionFactory); Iterator<?> getElements(Filter filter, int offset, int maxResultSize); @Override Object create(Object feature); @Override Object saveOrUpdate(Object feature); @Override void delete(String featureId); @Override Object read(String featureId); void update(Object feature); @Override Envelope getBounds(); Envelope getBounds(Filter filter); @Override List<Attribute<?>> getAttributes(String attributeName, Filter filter); DateFormat getDateFormat(); void setDateFormat(DateFormat dateFormat); boolean isScrollableResultSet(); @Api void setScrollableResultSet(boolean scrollableResultSet); }
HibernateLayer extends HibernateLayerUtil implements VectorLayer, VectorLayerAssociationSupport,
		VectorLayerLazyFeatureConversionSupport { public Iterator<?> getElements(Filter filter, int offset, int maxResultSize) throws LayerException { try { Session session = getSessionFactory().getCurrentSession(); Criteria criteria = session.createCriteria(getFeatureInfo().getDataSourceName()); if (filter != null) { if (filter != Filter.INCLUDE) { CriteriaVisitor visitor = new CriteriaVisitor((HibernateFeatureModel) featureModel, dateFormat); Criterion c = (Criterion) filter.accept(visitor, criteria); if (c != null) { criteria.add(c); } } } if (getFeatureInfo().getSortAttributeName() != null) { if (SortType.ASC.equals(getFeatureInfo().getSortType())) { criteria.addOrder(Order.asc(getFeatureInfo().getSortAttributeName())); } else { criteria.addOrder(Order.desc(getFeatureInfo().getSortAttributeName())); } } criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); if (isScrollableResultSet()) { return (Iterator<?>) new ScrollIterator(criteria.scroll()); } else { List<?> list = criteria.list(); return list.iterator(); } } catch (HibernateException he) { throw new HibernateLayerException(he, ExceptionCode.HIBERNATE_LOAD_FILTER_FAIL, getFeatureInfo() .getDataSourceName(), filter.toString()); } }  @Override String getId(); @Api void setId(String id); @Override CoordinateReferenceSystem getCrs(); @Override FeatureModel getFeatureModel(); @Override boolean useLazyFeatureConversion(); @Api void setUseLazyFeatureConversion(boolean useLazyFeatureConversion); @Api @Override void setLayerInfo(VectorLayerInfo layerInfo); @Override boolean isCreateCapable(); @Override boolean isUpdateCapable(); @Override boolean isDeleteCapable(); @Api void setFeatureModel(FeatureModel featureModel); @Api void setSessionFactory(SessionFactory sessionFactory); Iterator<?> getElements(Filter filter, int offset, int maxResultSize); @Override Object create(Object feature); @Override Object saveOrUpdate(Object feature); @Override void delete(String featureId); @Override Object read(String featureId); void update(Object feature); @Override Envelope getBounds(); Envelope getBounds(Filter filter); @Override List<Attribute<?>> getAttributes(String attributeName, Filter filter); DateFormat getDateFormat(); void setDateFormat(DateFormat dateFormat); boolean isScrollableResultSet(); @Api void setScrollableResultSet(boolean scrollableResultSet);  }