Swarup,
First, if you have complex query and big tables i advice that use ScrollableResults instead
setFirstResult/setMaxResult - it is better for Oracle, because hibernate for your solution make
ugly query with rownum and it is slow when you have big tables, order clause etc
setFirstResult/setMaxResult is preffered way for databass like mysql, postgresql - they read complete query in memory and have LIMIT clause for out of memory
oracle use cursors always and ScrollableResults is better
then you can find row count (and it is quick) with
Code:
Query q = ...;
ScrollableResults scr = q.scroll();
scr.last();
count = scr.getRowNumber() + 1;
use last 10g rel 2 driver, too