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
Post a Comment