-->
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: One-to-one mapping does not work for joined subclass
PostPosted: Mon May 18, 2009 12:14 pm 
Newbie

Joined: Sun Apr 12, 2009 4:43 am
Posts: 11
Hi
I have two tables; Person and Address (a Person has only one Address and it owns it; Address does not know about Person). Person and Address share the same primary key.
When I map Person and Address as follows:
Code:
<hibernate-mapping>
    <class name="Person" table="PERSON">
        <id name="id" type="long" column="PERSON_SEQ_NO">
           <generator class="native" />
        </id>
        <one-to-one name="address" class="Address" cascade="all" />
    </class>
</hibernate-mapping>
<hibernate-mapping>
     <class name="Address" table="ADDRESS">
        <id name="id" type="long" column="ADDRESS_SEQ_NO">
             <generator class="native" />              
        </id>
        <property name="line1" column="LINE_1"/>
        <property name="postcode" column="POSTCODE"/>
    </class>
</hibernate-mapping>

then I get a Person object with the right Address object set on them.
However, if I have a WibblePerson who extends Person and who should have a WibbleAddress (Person no longer has an Address), this mapping does not produce a one-to-one association:
Code:
<hibernate-mapping>
    <joined-subclass name="WibblePerson" extends="Person" table="WIBBLEPERSON">
        <key column="WIBBLE_PERSON_SEQ_NO"/>
        <one-to-one name="address" class="WibbleAddress" cascade="all" />
    </joined-subclass>
</hibernate-mapping>
<hibernate-mapping>
    <class name="WibbleAddress" table="WIBBLEADDRESS">
        <id name="id" type="long" column="WIBBLE_ADDRESS_SEQ_NO">
            <generator class="native" />
        </id>
        <property name="line1" column="LINE_1"/>
        <property name="postcode" column="POSTCODE"/>
    </class>
</hibernate-mapping>

Does anyone know why this is not possible?
thanks, Baljeet.


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.