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);  }
@Test public void testEmptyScrollableResultSet() throws Exception { Iterator<?> iterator = scrollableResultSetLayer.getElements(null, 0, 0); Assert.assertFalse(iterator.hasNext()); }
@Test public void testGetElements() throws Exception { layer.create(HibernateTestFeature.getDefaultInstance2(null)); Object feature = null; Iterator<?> iterator = layer.getElements(null, 0, 0); if (iterator.hasNext()) { feature = iterator.next(); } Assert.assertNotNull(feature); }