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: Many-to-many over non id field
PostPosted: Mon Jul 16, 2007 11:26 am 
Newbie

Joined: Wed Sep 27, 2006 7:40 am
Posts: 7
Hello!

I would like to make a many-to-many relation but one of the table is not connected with the id. I have 3 tables:

Table: FOO
PK: ID
ANOTHER_ID

Table: BAR
PK: ID

Table: FOOBAR
FOO_ID
BAR_ID

My problem is that FOO:ANOTHER_ID = FOOBAR:FOO_ID. So this mapping does not work:

<bag name="Bars" table="FOOBAR">
<key column="BAR_ID"/>
<many-to-many class="Bar" column="FOO_ID">
</many-to-many>
</bag>

What can I do to connect my tables?

Regards,
TheB


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 19, 2007 12:33 pm 
Newbie

Joined: Fri Jul 13, 2007 12:58 pm
Posts: 2
Hi,

I suppose you are in the Bar.hbm.xml.
So you can try this:

<bag name="Bars" table="FOOBAR">
<key column="BAR_ID"/>
<many-to-many class="FOO" column="FOO_ID">
</many-to-many>
</bag>

Regards,


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 19, 2007 5:22 pm 
Newbie

Joined: Wed Sep 27, 2006 7:40 am
Posts: 7
Hi TonyW,

No I'm in Foo.hbm.xml. What do I need Bars collection in Bar?

But you are right I've messed up the example. The right one looks like this:

<bag name="Bars" table="FOOBAR">
<key column="FOO_ID"/>
<many-to-many class="Bar" column="BAR_ID">
</many-to-many>
</bag>

My problem is that the relation between FOOBAR and FOO look like this: FOO:ANOTHER_ID -> FOOBAR:FOO_ID.

There has to by a way to solve such relation but!?

Regards,
TheB


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.