[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3487?page=c...
]
Will Hoover commented on HHH-3487:
----------------------------------
In the example the Actor class was final. according to
http://www.hibernate.org/hib_docs/reference/en/html/performance.html "you may not use
a CGLIB proxy for a final class or a class with any final methods". When final is
removed from the Actor class a proxy is used (as expected- see mapping example below).
<class name="Actor" table="ACTOR">
<id name="id" type="java.lang.Long">
<column name="ID" precision="22" scale="0"
/>
<generator class="assigned" />
</id>
<many-to-one name="actor" class="Actor">
<column name="PARENT_ID" precision="22"
scale="0" not-null="true" />
</many-to-one>
<set name="actors" inverse="true" >
<key>
<column name="PARENT_ID" precision="22"
scale="0" not-null="true" />
</key>
<one-to-many class="Actor" />
</set>
</class>
</hibernate-mapping>
Why would Hibernate query all of the single-ended relationships by default when a final
entity class is mapped? Seems odd that finalizing a mapped entity would cause such a
behavior. Wouldn't it be better to either throw an exception (or even log a message
stating that the relationship cannot be proxied) when this scenario occurs rather than
executing unnecessary queries?
DefaultLoadEventListener does not honor lazy load
(LoadEventListener.LoadType.INTERNAL_LOAD_LAZY)
-------------------------------------------------------------------------------------------------
Key: HHH-3487
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3487
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.1
Environment: N/A
Reporter: Will Hoover
Priority: Critical
DefaultLoadEventListener#doLoad(...) and
DefaultLoadEventListener#loadFromDatasource(...) does not honor
LoadEventListener.LoadType.INTERNAL_LOAD_LAZY
USE CASE:
1) Create Actor table with self-referencing parent/child relationship with the following
mapping- results in SessionImpl#internalLoad(...) setting LoadEventListener.LoadType to
LoadEventListener.LoadType.INTERNAL_LOAD_LAZY:
<hibernate-mapping>
<class name="Actor" table="ACTOR">
<id name="id" type="java.lang.Long">
<column name="ID" precision="22" scale="0"
/>
<generator class="assigned" />
</id>
<many-to-one name="actor" class="Actor"
lazy="no-proxy">
<column name="PARENT_ID" precision="22"
scale="0" not-null="true" />
</many-to-one>
<set name="actors" inverse="true" >
<key>
<column name="PARENT_ID" precision="22"
scale="0" not-null="true" />
</key>
<one-to-many class="Actor" />
</set>
</class>
</hibernate-mapping>
2) Add a parent/child relationship entries in database: ID:1,PARENT_ID:1 and
ID:2,PARENT_ID:1
3) Issue "Actor actor = (Actor) session.get(Actor.class, 1L);"
Results: Hibernate.isPropertyInitialized(actor, "actor") == true
--
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