|
have a generic method as shown below, make note of count(1) rather than count(*), as count(*) considers all the columns in each row, while calculation, count(1) gives more efficient results compared to count(*)
int queryStatus(String query){
String newquery = "select count(1) "+ query; // assumption, your query ll be "from tablename where crieteria=1"
Integer count = (Integer) session.createQuery(newquery).uniqueResult();
return count.intVal();
}
Also this depends on what you have in your where criteria of the query
|