/** * Update the context and clear the session if stateful. * * @param executionContext the current {@link ExecutionContext} * @throws ItemStreamException if there is a problem */ @Override public void update(ExecutionContext executionContext) throws ItemStreamException { super.update(executionContext); helper.clear(); }
/** * Read a page of data, clearing the existing session (if necessary) first, * and creating a new session before executing the query. * * @param page the page to read (starting at 0) * @param pageSize the size of the page or maximum number of items to read * @param fetchSize the fetch size to use * @param parameterValues the parameter values to use (if any, otherwise * null) * @return a collection of items */ public Collection<? extends T> readPage(int page, int pageSize, int fetchSize, Map<String, Object> parameterValues) { clear(); Query query = createQuery(); if (parameterValues != null) { query.setProperties(parameterValues); } @SuppressWarnings("unchecked") List<T> result = query.setFetchSize(fetchSize).setFirstResult(page * pageSize).setMaxResults(pageSize).list(); return result; }
/** * Update the context and clear the session if stateful. * * @param executionContext the current {@link ExecutionContext} * @throws ItemStreamException if there is a problem */ @Override public void update(ExecutionContext executionContext) throws ItemStreamException { super.update(executionContext); helper.clear(); }
/** * Read a page of data, clearing the existing session (if necessary) first, * and creating a new session before executing the query. * * @param page the page to read (starting at 0) * @param pageSize the size of the page or maximum number of items to read * @param fetchSize the fetch size to use * @param parameterValues the parameter values to use (if any, otherwise * null) * @return a collection of items */ public Collection<? extends T> readPage(int page, int pageSize, int fetchSize, Map<String, Object> parameterValues) { clear(); Query query = createQuery(); if (parameterValues != null) { query.setProperties(parameterValues); } @SuppressWarnings("unchecked") List<T> result = query.setFetchSize(fetchSize).setFirstResult(page * pageSize).setMaxResults(pageSize).list(); return result; }