[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-5465?page=c...
]
Andrew Tolopko commented on HHH-5465:
-------------------------------------
Commenting out lines 373-374 in org.hibernate.hql.ast.tree.FromElementFactory in
createCollectionJoin() appears to fix the reported issue, although I cannot say what ill
effects this may have elsewhere, since I have not attempted to run the full set of
Hibernate tests with this patch in place.
373: //origin.setText( "" ); // The destination node will have all the FROM
text.
374: //origin.setCollectionJoin( true ); // The parent node is a collection join too
(voodoo - see JoinProcessor)
Interestingly, note that line 372 was commented out back in 2005 to address HHH-242.
Finally, please note that in the originally attached test code, the classes EntityB and
EntityC erroneously include an EntityB data member, which should be removed. The existence
or absence of these data members does not affect the validity of the test code; it problem
persists in both cases. I will attach a new file containing the corrected classes for
EntityB and EntityC, as well as the patched FromElementFactory class, to demonstrate the
fix.
HQL left join fetch of an element collection following a left join
fetch of a one-to-one relationship causes NullPointerException
---------------------------------------------------------------------------------------------------------------------------------
Key: HHH-5465
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-5465
Project: Hibernate Core
Issue Type: Bug
Components: query-hql
Affects Versions: 3.5.4
Environment: Hibernate 3.5.4, Postgresql 8.4, Java 6
Reporter: Andrew Tolopko
Attachments: hibernate-left-fetch-join-element-collection.zip, log.txt
HQL queries of the form
"from EntityA a left join fetch a.entityB b left join fetch b.items"
fail with a NullPointerExeption when EntityA and EntityB have a one-to-one (@OneToOne)
relationship and EntityB.items is an element collection (@ElementCollection, aka
collection of values).
For comparison, the following HQL queries are all admissible (which intends to
demonstrate that no particular clause of the the above HQL is incorrect):
"from EntityB b left join fetch b.items"
"from EntityA a left join fetch a.entityB"
"from EntityA a left join fetch a.entityB.items"
"from EntityA a left join fetch a.entityCs c left join fetch c.items" (where
EntityA and EntityC have a one-to-many (@OneToMany) relationship, and EntityC.items is an
element collection)
Test code is attached. The log output along with thrown exception is attached as
log.txt.
--
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