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

Sandeep Vaid (JIRA) jira-events at lists.jboss.org
Fri Jul 3 09:36:51 EDT 2009


one-to-one with property-ref always non-lazy
--------------------------------------------

                 Key: HIBERNATE-119
                 URL: https://jira.jboss.org/jira/browse/HIBERNATE-119
             Project: Hibernate
          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 is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list