@Override public List<T> findAll(Context context, Class<T> clazz) throws SQLException { CriteriaQuery criteriaQuery = getCriteriaQuery(getCriteriaBuilder(context), clazz); Root<T> root = criteriaQuery.from(clazz); criteriaQuery.select(root); return executeCriteriaQuery(context, criteriaQuery, false, -1, -1); }
/** * This method will return a list with unique results, no duplicates, made by the given CriteriaQuery and parameters * * @param context * The standard DSpace context object * @param criteriaQuery * The CriteriaQuery for which this list will be retrieved * @param cacheable * Whether or not this query should be cacheable * @param clazz * The clazz for which this CriteriaQuery will be executed on * @param maxResults * The maxmimum amount of results that will be returned for this CriteriaQuery * @param offset * The offset to be used for the CriteriaQuery * @return A list of distinct results as depicted by the CriteriaQuery and parameters * @throws SQLException */ public List<T> list(Context context, CriteriaQuery criteriaQuery, boolean cacheable, Class<T> clazz, int maxResults, int offset) throws SQLException { criteriaQuery.distinct(true); @SuppressWarnings("unchecked") List<T> result = (List<T>) executeCriteriaQuery(context, criteriaQuery, cacheable, maxResults, offset); return result; }
/** * This method will return a list of results for the given CriteriaQuery and parameters * * @param context * The standard DSpace context object * @param criteriaQuery * The CriteriaQuery to be used to find the list of results * @param cacheable * A boolean value indicating whether this query should be cached or not * @param clazz * The class on which the CriteriaQuery will search * @param maxResults * The maximum amount of results to be returned * @param offset * The offset to be used for the CriteriaQuery * @param distinct * A boolean value indicating whether this list should be distinct or not * @return A list of results determined by the CriteriaQuery and parameters * @throws SQLException */ public List<T> list(Context context, CriteriaQuery criteriaQuery, boolean cacheable, Class<T> clazz, int maxResults, int offset, boolean distinct) throws SQLException { criteriaQuery.distinct(distinct); @SuppressWarnings("unchecked") List<T> result = (List<T>) executeCriteriaQuery(context, criteriaQuery, cacheable, maxResults, offset); return result; }
criteria.where(criteriaBuilder.equal(root.get(entry.getKey()), entry.getValue())); return executeCriteriaQuery(context, criteria, cacheable, maxResults, offset);