-->
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: unidirectional 1:1 association, join table, additional query
PostPosted: Wed Sep 21, 2005 2:31 am 
Newbie

Joined: Tue Sep 20, 2005 1:52 pm
Posts: 6
Hi all,

I try to figure out the following:

A class A (attributes a_id, b) has a 1:1 association (unidirectional) to class B (attribute b_id). The association is persisted in a join table AB (attributes a_id, b_id, discriminator). The 1:1 association can be found with the aid of the discriminator (lets say discriminator must be 'X'). The incomplete solution (for the mapping file A) might be:

<join table="AB"
optional="true">
<key column="a_id"
unique="true"/>
<many-to-one name="b"
column="b_id"
not-null="true"
unique="true"
class="B"/>
</join>

How can I add the additional condition "discriminator='X'" to the mapping ?

Thanks for any help,
Mike


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 21, 2005 5:11 am 
Beginner
Beginner

Joined: Tue Sep 20, 2005 4:32 am
Posts: 29
Location: Cluj-Napoca
Why don't you use class A (attributes a_id, b) and class B (attribute b_id,attributes a_id) with a_id like an foreign key to A and then use a one-to-one association ?


Top
 Profile  
 
 Post subject: unidirectional 1:1 association
PostPosted: Thu Sep 22, 2005 1:23 pm 
Newbie

Joined: Tue Sep 20, 2005 1:52 pm
Posts: 6
Hi Crista,

there are several reasons for this design (e.g. the join table contains in real world three types of associations). Isn't there any way to accomplish this mapping ?

Thanks,
Mike


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.