[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-5809?page=c...
]
David commented on HHH-5809:
----------------------------
So, from stepping through the code, I can see that Hibernate finds the association and
sees that it's associated by a BillingId object. It recognizes it as a primary key and
loads the key values (State,Country), creates a BillingId Object, and puts it into the
context cache. The problem seems to be that it never instantiates the Billing object so it
is never put into the context cache. When all the loading from the original query
happens, it iterates through each and every object in the context, looking for unitialized
values. Every time it finds a Person address, it (correctly) sees that the Billing object
has not been loaded yet, so it does the look-up with the BillingId object. So what looks
like needs to happen is that, in the ManyToOne Entity loader, the Billing objects needs to
be created, when a BillingId object is created, and the Billing objects needs to get put
into the context cache.
Mapping composite foreign key to composite primary key fails
------------------------------------------------------------
Key: HHH-5809
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-5809
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.5.6
Environment: Java Hibernate 3.5.6_FINAL, Oracle 11g
Reporter: David
I am seeing a problem similiar to the problems described at:
https://forum.hibernate.org/viewtopic.php?f=25&t=996445
I have mapped a composite foreign key to a primary composite key and it does not cache
the results properly. It's a bi-directional, many-to-one association mapped
essentially a cut+paste (with variable name substitution) from:
http://docs.jboss.org/hibernate/annotations/3.5/reference/en/html/entity....
but with a @NotFound set to IGNORE.
When I include the relationship in an HQL left fetch join, I can see that the Child's
Parent entity is placed in the session-cache. But when the Child class's getParent()
method is invoked, the result is loaded from the database instead of the session. It
completely ignores the session and the second-level cache, so I'm left with the N + 1
problem. If I enable batch fetch (size = 8), the entities loaded from the batch are also
not placed into either session cache (or level 2), so I get 1 + N (8-batch) fetches.
If the query runs again, everything correctly loads from the second-level cache.
Thanks.
--
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