-->
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.  [ 6 posts ] 
Author Message
 Post subject: joined subclasses - theoreticat question
PostPosted: Tue Mar 08, 2005 11:59 am 
Beginner
Beginner

Joined: Thu Mar 03, 2005 5:01 am
Posts: 33
Location: Wrocław (Poland)
Hibernate version: 3.0 rc 1

Hi,


I have small theoretical question :

Is it possible to have one-to-one association between two joined subclasses? If it is possible, please show me some mapping file content. I tried to do this, but I always got errors.

my post is quite similar to http://forum.hibernate.org/viewtopic.php?t=936631

thanks in advance,

greetings
Bimki


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 08, 2005 12:16 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Sure, just use a normal one-to-one foreign key association. Refer to the HB3 user manual for instructions.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 16, 2005 12:48 pm 
Beginner
Beginner

Joined: Thu Mar 03, 2005 5:01 am
Posts: 33
Location: Wrocław (Poland)
Please, give me an example. I tried to do it various ways. here You have example simple code :

Code:
<class name="A" table="A">
   
    <id name="id" column="ep_id" type="integer" unsaved-value="null">
      <generator class="increment" />
    </id>     
    <property name="typ" column="ep_typ" type="string" length="10" />
    <property name="data" column="ep_data" type="date" not-null="true" />
     
    <joined-subclass name="AB" table="AB">
      <key column="cza_id" />
      <property name="x" column="cza_x" type="integer" not-null="true" />
    </joined-subclass>

    <joined-subclass name="AC" table="AC">
      <key column="czz_id" />     
      <!--one-to-one name="dokument" class="AB" foreign-key="cza_id"/-->
    </joined-subclass>

</class>


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 24, 2005 5:48 pm 
Beginner
Beginner

Joined: Thu Mar 03, 2005 5:01 am
Posts: 33
Location: Wrocław (Poland)
I tried i.e something like this :

Code:
    <joined-subclass name="AC" table="AC">
      <key column="czz_id" />     
            .................

            <property name="AB" column="ab_id" type="integer"/>

            <one-to-one name="glownaAtomowa" class="AB"/>

    </joined-subclass>


but I got class-cast exception :(

I don't know where to put foreign key, You've written about...

_________________
bimki


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 24, 2005 6:14 pm 
Beginner
Beginner

Joined: Sun Sep 19, 2004 5:02 pm
Posts: 28
Location: Poland
In Hibernate 2.1 I would do this like this:

In AB:

<one-to-one name="ac" class="AC" property-ref="ab"/>

In AC:

<many-to-one name="ab" class="AB" column="AB_ID" unique="true"/>

PS: Pozdrowienia, tez jestem z Wrocka :)

_________________
Lmichasz


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 24, 2005 6:31 pm 
Beginner
Beginner

Joined: Thu Mar 03, 2005 5:01 am
Posts: 33
Location: Wrocław (Poland)
At last problem is solved!

Thanks, it works!!

ps. Pozdrowionka :)

_________________
bimki


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.