This content has been marked as final.
Show 4 replies
-
1. Re: Eager loading in EntityQuery
fhh Oct 29, 2007 5:59 AM (in response to zaya)Have you tried this?
SELECT c FROM Comment c INNER JOIN FETCH c.user
Regards
Felix -
2. Re: Eager loading in EntityQuery
zaya Oct 29, 2007 6:17 AM (in response to zaya)It gave such error:
org.hibernate.QueryException: query specified join fetching, but the owner of the fetched association was not present in the select list
-
3. Re: Eager loading in EntityQuery
zaya Oct 29, 2007 7:05 AM (in response to zaya)I read Hibernate doc, and it says:
Nor should fetch be used together with setMaxResults() or setFirstResult() as these operations are based on the result rows, which usually contain duplicates for eager collection fetching, hence, the number of rows is not what you'd expect.
EntityQuery used paging, there's certainly setMaxResults().
I'm kinda confused here. I executed generated mysql from mysql log, and the result seemed correct. Just the transaction was rolled back. -
4. Re: Eager loading in EntityQuery
zaya Oct 29, 2007 9:02 AM (in response to zaya)When I specify ejbql="select c from Comment c inner join fetch c.user" in components.xml, the generated ejbql is correct, but to retrieve the count number, it generated "select count(*) from Comment inner join fetch c.user where ......", that's wrong.
There isn't setCountEjbql() method either in EntityQuery or in Query. I have to extend the class. And because there is WHERE clause appended, I too have to recalculate the String, which is annoying and redundant.
Created Jira issue:
http://jira.jboss.com/jira/browse/JBSEAM-2177
And thanks fhh, I think you're correct.