is there some-more fit proceed origination pagination hibernate executing name count queries?


usually pagination queries feeling this. there improved proceed instead origination twin roughly equal methods, executing "select *..." "count *..."?



public list<cat> findcats(string name, int offset, int limit) {

query q = session.createquery("from cat where name=:name");

q.setstring("name", name);

(offset > 0) {
q.setfirstresult(offset);
}
(limit > 0) {
q.setmaxresults(limit);
}

relapse q.list();

}

public enlarged countcats(string name) {
query q = session.createquery("select count(*) cat where name=:name");
q.setstring("name", name);
relapse (long) q.uniqueresult();
}


Comments

Popular posts from this blog

list macos calm editors formula editors

how hibernate @any-related annotations?

why does floated <input> control floated component slip over too distant right ie7, nonetheless firefox?