Archive for September, 2007

Totally FREE !!!!!!!!!!

List utypesList = hs.createSQLQuery("SELECT {utypes.*} FROM utypes LIMIT 0,10") 
			.addEntity("utypes", Utypes.class) 
			.list();
 
if (!utypesList.isEmpty()) { 
	iterator iter = utypesList.iterator(); 
	while (iter.hasNext()) { 
		Utypes utypeBean = (Utypes)iter.next(); 
	} 
}

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 );