-->
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.  [ 1 post ] 
Author Message
 Post subject: bidirectional one-to-one trouble. inheritance used.
PostPosted: Fri Dec 19, 2008 9:17 am 
Newbie

Joined: Thu Dec 04, 2008 5:39 am
Posts: 1
Hi,

I have trouble in one of my bidirectional one-to-one associations, using foreign key associations. I'm gonna try to keep it as simple as possible.
I have three classes, lets say Aaa, Bbb and Ccc, where Ccc extends Bbb and Bbb extends some other class. I implemented a one-to-one association between Aaa and Ccc; mapping files are as follows:
Code:
   <class name="Aaa" ...>
      ...
      <many-to-one name="ccc" class="Ccc"
         column="CCC_ID" cascade="all" unique="true"/>
      ...
   </class>

   <class name="..." ...>
      ...
      <subclass name="Bbb">
         ...
         <subclass name="Ccc" discriminator-value="..">
            ...
            <one-to-one name="aaa" class="Aaa"
               property-ref="ccc" />
            ...
         </subclass>
         ...
      </subclass>
      ...
   </class>

The problem:

when no entity is attached to the session, I want to retrieve a Ccc object by its id.
session.get(Ccc.class, id) works fine, no problem. but
session.get(Bbb.class, id), the returned Ccc object's aaa property is null.

I totally understand why this happens, but I want to know if there is a solution to this other than declaring <many-to-one> in both sides.

Thanks in advance..


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

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.