-
15. Re: EntityManager's Native Query & Paging Results
rabbiaqaswar Jun 17, 2008 9:23 AM (in response to rabbiaqaswar)
This property is already set in the persistence.xml file along with the batch size property which i mentioned earlier. -
16. Re: EntityManager's Native Query & Paging Results
jaikiran Jun 19, 2008 2:34 AM (in response to rabbiaqaswar)I am running out of ideas. The only other suggestion i can give you is to use the correct (perhaps the latest) JDBC driver of Oracle.
-
17. Re: EntityManager's Native Query & Paging Results
rabbiaqaswar Jun 19, 2008 4:26 AM (in response to rabbiaqaswar)
:) Thanks
Should i report it as a bug at Hibernate? Maybe it is something wrong at their end? -
18. Re: EntityManager's Native Query & Paging Results
jaikiran Jun 19, 2008 8:46 AM (in response to rabbiaqaswar)I would suggest posting in the Hibernate forums instead of filing a bug.
-
19. Re: EntityManager's Native Query & Paging Results
rabbiaqaswar Jun 19, 2008 8:59 AM (in response to rabbiaqaswar)I did, three days back but got no reply from there:
http://forum.hibernate.org/viewtopic.php?t=987845&highlight= -
20. Re: EntityManager's Native Query & Paging Results
rabbiaqaswar Jun 19, 2008 9:02 AM (in response to rabbiaqaswar)One thing which I have noticed is that the query returns ids only for the first ten records. After that, it always returns the Object[] e.g. setFirstResult(20) & setMaxResults(10), also gives Object[]'s.
-
21. Re: EntityManager's Native Query & Paging Results
rabbiaqaswar Jun 19, 2008 9:09 AM (in response to rabbiaqaswar)
Infact it gives ids only when the setFirstResult is set at 0 i.e. setFirstResult(0). When the value of setFirstResult is anything other than 0, the query returns Object[]'s. -
22. Re: EntityManager's Native Query & Paging Results
jaikiran Jun 19, 2008 9:28 AM (in response to rabbiaqaswar)The indexing starts with 1 and not 0. So when setFirstResult(0) is used, it probably gets ignored.
-
23. Re: EntityManager's Native Query & Paging Results
rabbiaqaswar Jun 19, 2008 9:32 AM (in response to rabbiaqaswar)
So does that mean that the query is supposed to return Object[] containg the result & the index, even if i am only retreiving a single value in the query? -
24. Re: EntityManager's Native Query & Paging Results
jaikiran Jun 19, 2008 9:43 AM (in response to rabbiaqaswar)"jaikiran" wrote:
The indexing starts with 1 and not 0. So when setFirstResult(0) is used, it probably gets ignored.
I'm sorry. i re-read the javadocs and it appears the indexing does start from 0."rabbiaqaswar" wrote:
So does that mean that the query is supposed to return Object[] containg the result & the index, even if i am only retreiving a single value in the query?
*As far as i know*, that's not how its expected to behave. The query output should be the same number of columns that you have mentioned in the select clause. -
25. Re: EntityManager's Native Query & Paging Results
rabbiaqaswar Jun 19, 2008 9:44 AM (in response to rabbiaqaswar)I just checked the javadoc of javax.persitence.Query, method setFirstResult and it says:
Query setFirstResult(int startPosition)
Set the position of the first result to retrieve.
Parameters:
startPosition - the start position of the first result, numbered from 0
Returns:
the same query instance
Throws:
IllegalArgumentException - if argument is negative
So the index must be starting from 0. Even in my query the first result i get when i setFirstResult to 0 is the user id in first row in the table and get the second id when the setFirstResult is set to 1. -
26. Re: EntityManager's Native Query & Paging Results
jaikiran Jun 19, 2008 9:48 AM (in response to rabbiaqaswar)How about changing your query to return the entire User object instead of just the ids? Maybe like this:
SELECT USR FROM USER USR, USERWATCH UW WHERE USR.ADDEDBYID =1 AND USR.COUNTRY = CAS E WHEN (UW.COUNTRY is null) THEN USR.COUNTRY ELSE UW.COUNTRY END AND USR.ALIVE = 'A'
See if that works. -
27. Re: EntityManager's Native Query & Paging Results
rabbiaqaswar Jun 19, 2008 9:53 AM (in response to rabbiaqaswar)
Okay, will try this now then.
Thanks