HQL left join fetch of an element collection following a left join fetch of a one-to-one relationship causes NullPointerException

Description

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.

Environment

Hibernate 3.5.4, Postgresql 8.4, Java 6

Activity

Show:
Christian Beikov
May 4, 2012, 8:24 AM
Edited

Will this bug be fixed soon or just ignored?
There is a patch avilable, why not run the test and include the fix in the next release??

Christian Beikov
May 16, 2012, 5:16 AM

This also fails when the relationship between EntityA and EntityB is a ManyToOne-Relation!!!
This bug is really annoying, please include the fix in the next release!

Christian Beikov
April 27, 2013, 11:47 AM

Another testcase for this bug

Christian Beikov
May 2, 2013, 7:57 AM
Christian Beikov
July 30, 2013, 2:03 AM

Would anyone mind backporting the fix for this issue to the 4.2.x branch?

Fixed

Assignee

Steve Ebersole

Reporter

Andrew Tolopko

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major