[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2277?page=c...
]
Steve Ebersole commented on HHH-2277:
-------------------------------------
Actually 2-phase load will not even help here. 2-phase load still has an implied contract
that the ids all be resolved up front. And that is unfortunately the issue here. In
other words, given:
{noformat}
Customer( long id )
Order( PK id( Customer customer, long orderNumber ) )
{noformat}
The algorithm performed by Loader to read a row is
# read all keys from the result set
# read all values from the result set
In the problematic case, this means that it tries to:
# read the Order key from the result set
# read the Customer key from the result set
# read the Order values from the result set (using 2-phase load)
# read the Customer values from the result set (using 2-phase load)
(the order of Customer/Order here is irrelevant)
So in step (1) it is unable to resolve the Order key fully because Customer has not yet
been processed. Since it does not "see" the Customer it attempts to load it,
which forces the Loader to basically just get called again (hence the infinite loop).
The other issue here with *just* having a 2-phase load for components is that the order in
which these get processed from the result set now becomes important.
The only option I see is some form of "order aware" solution, where the Loader
knows about the relationship between the persisters it is processing (it does sorta/kinda
in that the order of the persisters returned by
org.hibernate.loader.Loader#getEntityPersisters is semi-important). Really what needs to
happen here specifically is that Customer needs to be at least in a state where it has
been added to the PersistenceContext in LOADING state prior to processing Order or its
key. This means, though, a pretty drastic change to the internals of Loader.
The thing to be aware of on the other side is to not "go too far" in processing
Customer, specifically in resolving its associations, since those associations mey still
be awaiting processing from the current result set.
bidirectional <key-many-to-one> both lazy=false fetch=join lead
to infinite loop
--------------------------------------------------------------------------------
Key: HHH-2277
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2277
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.2.1
Reporter: Emmanuel Bernard
Assignee: Steve Ebersole
Fix For: cfg-rework
--
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