/* (non-Javadoc) * @see fr.certu.chouette.dao.IDaoTemplate#getAll() */ public List<T> getAll() { logger.debug("invoke getAll on " + type.getSimpleName()); // return getHibernateTemplate().loadAll(type); // wrong call, may contains duplicate entry if join clause Filter f = Filter.getNewEmptyFilter(); return select(f); }
@Override public long count(Filter clause) { if (clause == null) clause = Filter.getNewEmptyFilter(); Session session = getSession(); FilterToHibernateClauseTranslator translator = new FilterToHibernateClauseTranslator(); String hql = translator.translateToHQLCount(clause, getSessionFactory().getClassMetadata(type)); logger.debug("hql = " + hql); if (translator.getValues().isEmpty()) return ((Long) session.createQuery(hql).uniqueResult()).longValue(); else { Query query = session.createQuery(hql); int pos = 0; for (Object value : translator.getValues()) { query.setParameter(pos++, value); } return ((Long) query.uniqueResult()).longValue(); } }