@Override public int getCount(DaoFilter daoFilter) throws DaoException{ DSLContext context = getJooq(); try { Collection<Condition> conditions = new ArrayList<Condition>(); if (daoFilter.getLangIds() != null) { conditions.add(Tables.CATEGORY_MEMBERS.LANG_ID.in(daoFilter.getLangIds())); } return context.selectCount(). from(Tables.CATEGORY_MEMBERS). where(conditions). fetchOne().value1(); } finally { freeJooq(context); } }
/** * This method should generally not be used. * @param daoFilter a set of filters to limit the search * @return * @throws DaoException */ @Override public Iterable<LocalCategoryMember> get(DaoFilter daoFilter) throws DaoException { DSLContext context = getJooq(); try { Collection<Condition> conditions = new ArrayList<Condition>(); if (daoFilter.getLangIds() != null) { conditions.add(Tables.CATEGORY_MEMBERS.LANG_ID.in(daoFilter.getLangIds())); } Cursor<Record> result = context.select(). from(Tables.CATEGORY_MEMBERS). where(conditions). limit(daoFilter.getLimitOrInfinity()). fetchLazy(getFetchSize()); return new SimpleSqlDaoIterable<LocalCategoryMember>(result, context) { @Override public LocalCategoryMember transform(Record r) { return buildLocalCategoryMember(r); } }; } catch (RuntimeException e) { freeJooq(context); throw e; } }
@Override public Collection<Integer> getCategoryMemberIds(Language language, int categoryId) throws DaoException { DSLContext context = getJooq(); try { Result<Record> result = context.select(). from(Tables.CATEGORY_MEMBERS). where(Tables.CATEGORY_MEMBERS.CATEGORY_ID.eq(categoryId)). and(Tables.CATEGORY_MEMBERS.LANG_ID.eq(language.getId())). fetch(); return extractIds(result, false); } finally { freeJooq(context); } }
@Override public Collection<Integer> getCategoryIds(Language language, int articleId) throws DaoException { DSLContext context = getJooq(); try { Result<Record> result = context.select(). from(Tables.CATEGORY_MEMBERS). where(Tables.CATEGORY_MEMBERS.ARTICLE_ID.eq(articleId)). and(Tables.CATEGORY_MEMBERS.LANG_ID.eq(language.getId())). fetch(); return extractIds(result, true); } finally { freeJooq(context); } }