[hibernate-issues] [Hibernate-JIRA] Created: (HHH-4906) Collection incorrectly populated after LEFT_JOIN query with restriction on child

Viliam Ďurina (JIRA) noreply at atlassian.com
Thu Feb 11 03:06:38 EST 2010


Collection incorrectly populated after LEFT_JOIN query with restriction on child
--------------------------------------------------------------------------------

                 Key: HHH-4906
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4906
             Project: Hibernate Core
          Issue Type: Bug
          Components: caching (L2)
    Affects Versions: 3.3.1
         Environment: Hibernate 3.3.1, but first encountered this but over a year ago.
Database is Oracle 10g, but think it is DB-independent.
            Reporter: Viliam Ďurina
         Attachments: testcase.zip

If you have two classes in one to many relationship (call them parent and child) and query the parent class with left-joined child with a restriction on a field of the child class, then the parent class's children collection is incorrectly initialized with a children list filtered by that restriction.

Seems as incorrect optimization: Hibernate thinks the children collection is complete and initializes it from the query and caches it. If you replace LEFT_JOIN with INNER_JOIN, it works: the children collection is initialized in the moment it is first accessed by a separate query. But actually, in this case it has nothing to do with LEFT or INNER join, but with restrictions on the children association.

See attached test case: run the Test class and see, that the children collection has only one item instead of three. Replace left join with inner and see that it works.

-- 
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.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       



More information about the hibernate-issues mailing list