Beginner |
|
Joined: Tue Jan 27, 2004 8:33 am Posts: 29
|
1) I'm sorry I keep on posting but I can't use the search on the forum...
Is there a way to look for a string instead of a boolean expression?
It's hard to look for "number of rows" using "number and rows"...
2) I have to divide a list of objects into "pages" of data.
I'm using setMaxResults and setFirstResult, but the very first time
the user asks for the list I want to know the total number of rows.
What's the faster method?
a)
if (firstTime) {
totrows = query.list().size() // without setMaxResults or setFirstResult
}
query.setMaxResults(..)
query.setFirstResult(..)
List mylist = query.list() // re-query
b) use another query with "select count(*)" just before the "real" query:
if (firstTime){
totrows = ((Integer)query2.iterate().next()).intValue()
}
//now the "normal" query
query.setMaxResults(..)
query.setFirstResult(..)
List mylist = query.list()
|
|