HI! this a sample of a code in hibernate 2 :
public List findAllByCommercialElement(CommercialElement commercialElement) throws GCETechnicalException { return GCEHibernateHelper.findAllByCriterion( CommEltRTCToNetworkEltRTC.class, "commercialElement", commercialElement, Hibernate.entity(commercialElement .getClass())); } After upgrade to hibernate 3.6.3, the method "entity"( entity(commercialElement.getClass()))) is deprecated. Further more, performance tests show that all methods that call "findAllByCriterion" are at least two more slow in hibernate 3.6.3
Question : is someone know how to good implement methods with Criteria ? Actually this is how is it : try { Criteria crit = session.createCriteria(searchClass); crit.add(Expression.eq(searchProperty, searchValue)); crit.setCacheable(true);
if (rownum > 0) crit.setMaxResults(rownum);
return crit.list();
} catch (HibernateException he) { throw new GCETechnicalException(GCETechnicalException.QUERY_ERROR, "GCEHibernateHelper.findAllByCriterion", he); } HELP ?
|