-->
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.  [ 5 posts ] 
Author Message
 Post subject: Multi part key set (many to one)?
PostPosted: Wed Sep 10, 2003 2:24 pm 
Beginner
Beginner

Joined: Thu Sep 04, 2003 5:38 pm
Posts: 29
I am just missing this one!

For each foo, each can contain a collection of Bar. This example is in the docs:

<set name="bars">
<key column="foo_id"/>
<one-to-many class="com.illflow.Bar"/>
</set>


But what if I have a two part key, say the Bar.X and Bar.Y has to be tied to my Foo.X and Foo. I am not sure how to specify this. I am not even sure in this example how it knows what field in Bar foo_id joins to except perhaps it assumes the ID?

rick


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 10, 2003 2:26 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
The documentation covers this!

You use the <column> subelement of <key>.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 10, 2003 2:42 pm 
Beginner
Beginner

Joined: Thu Sep 04, 2003 5:38 pm
Posts: 29
Ok, I mistyped (been at it too long!). I meant one to many.

I did think I could do this, but am also using xdoclet. When I can't get it to generate, so maybe it's an xdoclet issue after all. I can't wrestle it to do it yet. I tried this:

@hibernate.collection-key
@hibernate.column="A"
@hibernate.column="B"

which I thought would work, but it just makes a <key column=""/> and that's it. So it may be I should ask this of the xdoclet guys.

rick


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 10, 2003 2:50 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
being that i'm the guy who added the @hibernate.column tag to the xdoclet module, I guess I should take the rap for it not really working here ;)

if I were you, I wouldn't try to use xdoclet with composite keys .... its just not really a good combination, for a number of reasons.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 10, 2003 2:55 pm 
Beginner
Beginner

Joined: Thu Sep 04, 2003 5:38 pm
Posts: 29
Ok, that's out.
I just tried using the where clause for set, thinking perhaps I could do my "joining" there, but it seems that I can't reference all the columns i need in there.

Looks like the best bet is a merge file for xdoclet to suck in, I'll try that next.


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