1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
public List<IdentiteBancaire> findByParamsAndPage(final String requestName,
final String[] params, final Object[] values, final int page,
final int nb) throws DaoException {
List<IdentiteBancaire> list = new ArrayList<IdentiteBancaire>();
log.debug("debut de recherche des objets IdentiteBancaire : request : "
+ requestName
+ " : params : "
+ params.toString()
+ " : values : "
+ values.toString()
+ ": page : "
+ page
+ ": nb : " + nb);
try {
list = (List<IdentiteBancaire>) getHibernateTemplate().execute(
new HibernateCallback() {
public Object doInHibernate(Session session)
throws HibernateException, SQLException {
Query query = session.getNamedQuery(requestName);
if (params != null && params.length > 1) {
for (int i = 0; i < params.length; i++) {
query.setParameter(params[i], values[i]);
}
}
if (page > 0 && nb > 0) {
query.setFirstResult((page - 1) * nb);
query.setMaxResults(nb);
}
return query.list();
}
});
} catch (Exception re) {
log.error("erreur de recherche ", re);
throw new DaoException(re);
}
log.debug("fin de recherche des objets IdentiteBancaire ");
return list;
} |
Partager