[jboss-jira] [JBoss JIRA] (HIBERNATE-119) one-to-one with property-ref always non-lazy

Steve Ebersole (JIRA) issues at jboss.org
Thu Nov 19 10:32:00 EST 2015


     [ https://issues.jboss.org/browse/HIBERNATE-119?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Steve Ebersole closed HIBERNATE-119.
------------------------------------
    Resolution: Rejected


> one-to-one with property-ref always non-lazy
> --------------------------------------------
>
>                 Key: HIBERNATE-119
>                 URL: https://issues.jboss.org/browse/HIBERNATE-119
>             Project: Hibernate Integration
>          Issue Type: Feature Request
>            Reporter: Sandeep Vaid
>            Assignee: Steve Ebersole
>
> I have one-to-one relationship between Product and ProductBasic.
> PRODUCT ------> PRODUCTID(PK)
> PRODUCT ------> PID, CODE, STARTTIME (Composite-key) and PID is FK
> In product.hbm.xml
>  <one-to-one name="productBasic" cascade="save-update" property-ref="activeProduct" constrained="true">
>     <formula>PRODUCTID</formula>
>  </one-to-one>
>  
>  
>  ProductBasic.hbm.xml as :
>  <properties name="activeProduct">
>    <many-to-one name="product" class="Product"  insert="false" update="false" lazy="proxy" />
>  </properties>
>   
>   
>   When i am using property-ref, and try to load all Products, it fetches ProductBasic also as :
>   select * from PRODUCT;   //suppose it return 2 records with productId as 100 and 101 respectively.
>   select * from PRODUCTBASIC where productId='100'
>   select * from PRODUCTBASIC where productId='101'
>  
>   How can i fetch ProductBasic in a Non-Lazy manner in this case.
> I found few information regarding my problem as :
> https://forum.hibernate.org/viewtopic.php?f=25&t=969713
>  NOTE: Without property-ref, we can load one-to-one lazily (by sepcifying constrained="true")....... outer-join="true"
>   It's shows the message as :
>   DEBUG - total objects hydrated: 1
>   DEBUG - resolving associations for [model.Product#1]
>   DEBUG - loading entity: [model.ProductName#1]
>   DEBUG - creating new proxy for entity
>   DEBUG - done materializing entity [model.Product#1]
>  
>   Now the thing now remaining in this is to load one-to-one lazily with property-ref.
>   EntityType.resolve() line 382
>       if ( isReferenceToPrimaryKey() ) {
>  	return resolveIdentifier( (Serializable) value, session );
>        }
>       else {
>         return loadByUniqueKey( getAssociatedEntityName(), uniqueKeyPropertyName, value, session );
>        }
>      
>      and in loadByUniqueKey() method, there is a comment :
>      //TODO: implement caching?! proxies?!
>      
>    I think this is the culprit  



--
This message was sent by Atlassian JIRA
(v6.4.11#64026)


More information about the jboss-jira mailing list