-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: one-to-one mapping
PostPosted: Mon Feb 02, 2009 3:39 pm 
Senior
Senior

Joined: Thu Jan 08, 2009 3:48 pm
Posts: 168
This is a follow-up to this post, especially nordborg's explanation about one-to-one

Problem is as follows:

Start a->b , a->c , c->d are all mapped one-to-one

Code:
ClassA
  <one-to-one name="bees" class="ClassB" />
  <one-to-one name="cees" class="ClassC" property-ref="a_id"/>
    <one-to-one name="dees" class="ClassD" property-ref="c_id"/>


Result on refreshing a:
select ... from a_table
select ... from b_table, c_table, d_table

Then i changed it to a->b and c->d both constrained and lazy:

Code:
ClassA
  <one-to-one name="bees" class="ClassB" constrained="true" lazy="proxy" />
  <one-to-one name="cees" class="ClassC" property-ref="a_id"/>
    <one-to-one name="dees" class="ClassD" property-ref="c_id" constrained="true" lazy="proxy" />


Result on refreshing a:
select ... from a_table
select ... from c_table

But what didn't fit in was when i changed it to a->c being constrained and lazy

Code:
ClassA
  <one-to-one name="bees" class="ClassB" constrained="true" lazy="proxy" />
  <one-to-one name="cees" class="ClassC" property-ref="a_id" constrained="true" lazy="proxy" />
    <one-to-one name="dees" class="ClassD" property-ref="c_id" constrained="true" lazy="proxy" />


Result on refreshing a:
select ... from a_table
select ... from c_table

So data from c_table is always loaded, any thoughts why this happens and how to prevent it?
I know it's doable with many-to-one but i just want to know whis this happens with one-to-one.

Thanks in advance

Patrik


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 03, 2009 4:46 am 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
That really seems to be weird, as "cees" and "dees" are mapped exactly the same way, but your property-ref. But maybe thats the problem:
Property-ref is the part, which I don't understand in your mapping. Do you really have a property "private ClassA c_id" in ClassD?? Because this is what your mapping states. Notice that property-ref is used, when you join a bidirectional one-to-one association on a foreign key instead of using the same primary key.

_________________
-----------------
Need advanced help? http://www.viada.eu


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 03, 2009 4:59 am 
Senior
Senior

Joined: Thu Jan 08, 2009 3:48 pm
Posts: 168
Sorry I didn't write that clear enough
ClassA
- ClassB
- ClassC

ClassC
- ClassD

ClassD is mapped in ClassC the same way as ClassC is mapped in ClassA (with property_ref)

ClassC has an "a_id"
ClassD has and "c_id"

ClassA and ClassB share the same primary key


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.