Query#scroll fetches only parts of ManyToMany collections on join fetch
-----------------------------------------------------------------------
Key: HHH-5496
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-5496
Project: Hibernate Core
Issue Type: Bug
Components: query-hql
Affects Versions: 3.5.2, 3.5.0-Final, 3.3.2
Environment: Reproduced on 3.3.2, 3.5.0-Final and 3.5.2-Final
Reporter: Christian Köberl
Attachments: manyToManyScrollFetch.zip
h3. Description
If you have an entity A with a many-to-many relationship to another entity B and try to
scroll over a result by "SELECT DISTINCT a FROM A a LEFT JOIN FETCH a.b" then
only some elements of b are returned. If you do a list on the query everything is
returned. See example project attached as zip.
The documentation states that differently:
??The fetch construct cannot be used in queries called using iterate() (though scroll()
can be used)??
(
http://docs.jboss.org/hibernate/stable/core/reference/en/html_single/#que...)
h3. Information about the example project
In the example project there are 2 entities Vehicle and Tag with a many-to-many
relationship.
The Main program inserts 20 vehicles: 10 with 2 Tags "TAG1" and
"TAG2", 10 without any tags.
After that the the query "SELECT DISTINCT v FROM Vehicle v LEFT JOIN FETCH
v.vehicleTags ORDER BY v.id" is executed via scroll and list and the results are
logged.
You can see that the scroll result does only show both tags for the first vehicle, the
rest have only one tag. The list result shows both tags on all 10 tagged vehicles.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira