Is there a way in JAVA hibernate to execute a criteria query and projections count on that same query in a single trip to the DB?
The reason for wanting this is getting the most efficient way to page results, i was hoping to do the following
start transaction
start db call
do query()
do count()
end db call
end transaction
what i’m currently doing is
start transaction
start db call
do query()
end db call
start db call
do count()
end db call
end transaction
I really looked into this about a year ago and the best I came up with was executing both database operations in the same transaction. It is still two separate database hits, but it eliminates somewhat embarrassing headers like records 1-50 from 45.