Archive for September 19th, 2007

Count all rows of a table

Hibernate request to count table rows:

int paginationSize = 10;
int pages = 0;
float countCities = 0;
 
List countCitiesList = hs.createSQLQuery("SELECT count(id) AS count FROM cities")
	.addScalar("count",  Hibernate.INTEGER)
	.list();
 
if (!countCitiesList.isEmpty()) {
	Iterator tmp_iter = countCitiesList.iterator();
	while (tmp_iter.hasNext()) {
	    	Integer tmp_ii = (Integer)tmp_iter.next();
	        countCities = tmp_ii.floatValue();
	}
}
 
pages = Math.round( countCities / paginationSize );

Java Basics

Only round this result of this java operation.

 
int pages = Math.round( countCities / paginationSize );

Simple ajax calls

To make an ajax call in jquery, might be helpful, or not, depends on Remy Sharp

$(div).load('listMastersResponse', { action: "showdir", name: span.innerHTML, path: hidden.value } );