From project faces, under directory /Proyectos/cinedayz/src/main/java/pe/joedayz/ejemplos/cinedayz/core/.
Source file: GenericoDAO.java
public Integer obtenerTamanho(final Busqueda filtro){
return (Integer)this.getHibernateTemplate().execute(new HibernateCallback(){
@Override public Object doInHibernate( Session session) throws HibernateException, SQLException {
Projection total=Projections.rowCount();
filtro.setProjection(total);
Integer resultado=(Integer)filtro.getExecutableCriteria(session).uniqueResult();
filtro.setProjection(null);
return resultado;
}
}
);
}
Example 2
From project onebusaway-nyc, under directory /onebusaway-nyc-report-archive/src/test/java/org/onebusaway/nyc/report_archive/impl/.
Source file: NycQueuedInferredLocationDaoImplTest
@SuppressWarnings("unchecked") private int getNumberOfRecords(){
@SuppressWarnings("rawtypes") Long count=(Long)_dao.getHibernateTemplate().execute(new HibernateCallback(){
public Object doInHibernate( Session session) throws HibernateException {
Query query=session.createQuery("select count(*) from ArchivedInferredLocationRecord");
return (Long)query.uniqueResult();
}
}
);
return count.intValue();
}