-->
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: More explanation on key-many-to-one
PostPosted: Fri Nov 05, 2004 9:42 am 
Expert
Expert

Joined: Thu Sep 04, 2003 8:23 am
Posts: 368
Hi,

In the book there is a sentence about key-many-to-one that says
Quote:
However, it's usually inconvenient to have an association in a composite identifier class, so this approach isn't recommended except in special circumstances


Is it possible to have any explanation on this. Why it is not recommended to use 'key-many-to-one' ?

Thanx for your help

Seb


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 05, 2004 5:39 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Well, key-many-to-one just sucks in Hibernate. Use a key-property and a many-to-one mapped with update/insert=false.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 09, 2004 4:06 am 
Expert
Expert

Joined: Thu Sep 04, 2003 8:23 am
Posts: 368
So this is just an hibernate restriction ?

I don't like your proposition because the new property is just here for an hibernate purpose. It pollutes my domain model.

Maybe there is another solution. I have a parent/child relationship. I want the child pk to be a composition of the parent id and another relation.

For me the best way to design this with hibernate is to use a composite-element. My problem is just a schema generation relative problem. I cannot with this design generate a pk on my composite-element table. So I tried to do it with a one-to-many relation but this leads me in a key-many-to-one on the child element. I am so just curious on why this is a bad idea.

If somebody can tell me how to generate my pk on my child table with a composite-element I think this would be the best way to do

Thanx

Seb


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.