[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-3891) one-to-one with property-ref always non-lazy

radhakrishna (JIRA) noreply at atlassian.com
Sat Jul 18 16:30:14 EDT 2009


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3891?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=33630#action_33630 ] 

radhakrishna commented on HHH-3891:
-----------------------------------

one-to-one does not work to fetch lazily according to your whatever reasonings, but why is even many-to-one bringing the objects NON-lazily when property-ref is used in Hibernate3??

https://forum.hibernate.org/viewtopic.php?f=1&t=991369

"One-to-one will not work the way we want it as it just cannot be used to fetch lazily for 1<---->0 or 1 relationship, https://www.hibernate.org/315.html and https://www.hibernate.org/162.html

But why is the many-to-one being eagerly loaded, when property-ref is used?

A many-to-one maps with lazy="proxy" by default, meaning it does not eagerly fetch the parent object, however, I noticed that if I use the property-ref to map to an other property field, they it is by default doing an eager fetch, no matter what other property options I set."


> one-to-one with property-ref always non-lazy
> --------------------------------------------
>
>                 Key: HHH-3891
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3891
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: core
>            Reporter: Sandeep Vaid
>            Assignee: Diego Plentz
>
> I have one-to-one relationship betnwee Product and ProductBasic.
>   <one-to-one name="productBasic" cascade="save-update" property-ref="activeProduct" lazy="proxy">
>     <formula>'1'</formula>
>     <formula>PRODUCTID</formula>
>  </one-to-one>
>  
>  
>  ProductBasic.hbm.xml as :
>  <properties name="activeProduct">
>    <property  name="Code" column="CODE"></property>
>    <property  name="pId" column="PID" insert="false" update="false"></property>
>   </properties>
>   
>   
>   When i am using property-ref, and try to load Product, it eagerly fetches ProductBasic also as :
>   
>   select *
>   from PRODUCT productbo0_ left outer join PRODUCTPERIOD productbas1_ on '18'=productbas1_.CODE and productbo0_.PID=productbas1_.PID where productbo0_.PID=?
>   
>  NOTE: Along with Product, ProductBasic is also fetched in a single query.
>  
>  Even if i add constrained="true" in one-to-one mapping, the query gets fired as :
>   select * from PRODUCT productbo0_ where productbo0_.PID=?
>   select * from PRODUCTBASIC productbas0_ where productbas0_.CODE=? and productbas0_.PID=?
>   
>   NOTE: Along with Product, ProductBasic is also fetched in a different query.
>   
>   BUT in both these cases, ProductBasic is fetched always (non-lazy)..
>   
>   How can i fetch ProductBasic in a Non-Lazy manner in this case.

-- 
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.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list