[jboss-user] [EJB 3.0] - Re: EntityManager's Native Query & Paging Results

rabbiaqaswar do-not-reply at jboss.com
Tue Jun 17 04:56:09 EDT 2008


Thanks.

I enabled Trace and the two queries executed internally are actually different!

Here is the query which is executed with the setfirstResult(0) and setMaxResults(20):

select * from (SELECT DISTINCT USR.USERID FROM USER USR, USERWATCH UW WHERE  USR.ADDEDBYID =1 AND 
  | USR.COUNTRY = CASE WHEN (UW.COUNTRY is null) THEN USR.COUNTRY ELSE UW.COUNTRY END AND USR.ALIVE = 'A') where rownum <= ?

and for setFirstResult(10) and setMaxResult(10), the query is:
select * from ( select row_.*, rownum rownum_ from (SELECT DISTINCT USR.USERID FROM USER USR, USERWATCH UW WHERE  USR.ADDEDBYID =1 AND USR.COUNTRY = CASE WHEN (UW.COUNTRY is null) THEN USR.COUNTRY ELSE UW.COUNTRY END AND USR.ALIVE = 'A') row_ where rownum <= ?) where rownum_ > ?

Any idea, what is happening here?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4158629#4158629

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4158629



More information about the jboss-user mailing list