public List<T> getResults(final int from, final int to) { return sessionFactory.execute(new SessionCallback<List<T>>() { public List<T> doInSession(Session session) { BeanQuery qry = session.from(sources).offset(from).limit(to - from).orderBy(order); if (condition != null) { qry.where(condition); } return qry.list(projection); } }); }
@Override public int getAvailableRows() { return sessionFactory.execute(new SessionCallback<Integer>() { @Override public Integer doInSession(Session session) { BeanQuery beanQuery = session.from(entityPath); if (conditions != null) { beanQuery.where(conditions); } return (int) beanQuery.count(); } }); }
@Override public void prepare(final int start, final int end, final List<SortConstraint> sortConstraints) { Assert.notNull(sortConstraints, "sortContraints"); sessionFactory.execute(new SessionCallback<Void>() { @Override public Void doInSession(Session session) { prepare(session, start, end, sortConstraints); return null; } }); }
public BeanListSource(SessionFactory sessionFactory, EntityPath<?>[] sourceArray, QueryMetadata metadata, Path<T> projection) { this.sessionFactory = sessionFactory; this.sources = sourceArray.clone(); this.condition = metadata.getWhere(); this.projection = projection; this.order = metadata.getOrderBy().toArray(new OrderSpecifier[metadata.getOrderBy().size()]); this.size = sessionFactory.execute(new SessionCallback<Long>() { @Override public Long doInSession(Session session) { BeanQuery countQry = session.from(sources); if (condition != null) { countQry.where(condition); } return countQry.count(); } }); }