]
Steve Ebersole commented on HIBERNATE-119:
------------------------------------------
This is not the correct project to report Hibernate issues under. This Jira project is for
reporting issues in the integration between Hibernate and WildFly. To report issues in
Hibernate, please use
. Thanks.
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