-->
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.  [ 4 posts ] 
Author Message
 Post subject: double key-column for one-to-many-mappings
PostPosted: Tue May 25, 2004 10:10 am 
Beginner
Beginner

Joined: Thu Oct 30, 2003 6:29 am
Posts: 30
Location: Germany, KA
hi there,
i have problems with my bidrectional 1:m mapping. Assume the follwing:

I have an entity 'Class' and an entity 'Relation'.
'Relation' has a 'LeftClass' and a 'RightClass'. How do I write the mapping for 'Class' if I want to access all Relations, thus meaning all 'Relation'-entities that have this 'Class' as 'LeftClass' or as 'RightClass'.

my mapping so far:
'Class.hbm.xml'
...
<set
name="Relations"
lazy="true"
inverse="true"
cascade="save-update"
>
<key
column="WHAT GOES HERE??"
/>
<one-to-many
class="org.xinity.base.devtools.BlueprintRelation"
/>
</set>
...

'Relation.hbm.xml'
...
<!-- LEFTCLASS -->
<many-to-one
name="leftClass"
class="org.xinity.base.devtools.XBOBlueprint"
cascade="save-update"
outer-join="auto"
update="true"
insert="true"
column="LEFT_BLUEPRINT_FK"
/>


<!-- RIGHTCLASS -->
<many-to-one
name="rightClass"
class="org.xinity.base.devtools.XBOBlueprint"
cascade="save-update"
outer-join="auto"
update="true"
insert="true"
column="RIGHT_BLUEPRINT_FK"
/>
...

thanks for help
marie


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 25, 2004 11:25 am 
Senior
Senior

Joined: Fri Nov 21, 2003 5:55 am
Posts: 155
Read this documentation and examples in the hibernate doc

http://www.xylax.net/hibernate/


Top
 Profile  
 
 Post subject: double key-column for one-to-many-mappings
PostPosted: Tue May 25, 2004 11:52 am 
Beginner
Beginner

Joined: Thu Oct 30, 2003 6:29 am
Posts: 30
Location: Germany, KA
thanks.
but I can't get any help from this documentation, my problem is not a simple mapping but a maping with two key-columns. 'Class' is connected to 'Relation' by 'Relation.LeftClass' and 'Relation.RightClass'. I can access those two connected Classes from within 'Relation' but I can't access the Relations from within 'Class'.

Class (1) --- (many) Relation (many) --- (1) Class

Relation.getLeftClass(); [works fine]
Relation.getRightClass(); [works fine, too]
Class.getRelations(); [here is the Problem!]

I would have to do s.th. like:
[Class.hbm.xml}
<set name="Relations" lazy="true" inverse="true" cascade="save-update" >
<key column="RIGHT_CLASS_FK" />
<key column="LEFT_CLASS_FK" />
<one-to-many class="org.xinity.base.devtools.BlueprintRelation" />
</set>

but that does not work (of course).

any ideas?
thanks
marie


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 25, 2004 3:54 pm 
Senior
Senior

Joined: Fri Nov 21, 2003 5:55 am
Posts: 155
Ok so you have a many to many relationship between your 2 entities isnt'it?
So use a composite id or composite element to manage these two foreign keys


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