-->
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: Seperate Composite Key class. Why?
PostPosted: Thu Oct 07, 2004 12:35 pm 
Beginner
Beginner

Joined: Mon Jun 21, 2004 2:41 pm
Posts: 40
What are the reasons to have the composite keys in a seperate class file?

The Hibernate in Action book only indicates that it makes composite foreign keys easier to read and access. Pages 334 - 336.

http://www.hibernate.org/hib_docs/reference/en/html_single/#mapping-declaration-compositeid
Indicates that seperate composite key class is " a much more convenient approach". But it does not state why.

Also, I have been trying to use the Criteria API with the composite keys in a seperate class and it seems that having the composite keys in seperate class makes querying on the information more difficult.

I am leaning on going back to having the composite key integrated in the main class.

Thank you for your suggestions and input,
David W.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 07, 2004 3:02 pm 
Expert
Expert

Joined: Thu Jan 29, 2004 2:31 am
Posts: 362
Location: Switzerland, Bern
If you have the composite key in CompositeUserType, you can write an approriate IdentifierGenerator and have them assigend automatically by Hibernate. With compoiste-id s you have to do this yourself.

Further more if you want to use cascading it's much more convenient if you can let Hibernate everything figure out instead of checking yourself for unsaved values in an Interceptor.

HTH
Ernst


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 12, 2004 9:43 am 
Beginner
Beginner

Joined: Mon Jun 21, 2004 2:41 pm
Posts: 40
Hmm... I don't beleive that answered my question.

Also, in our case I don't think that we can use an IdentifierGenerator as there is no pattern between the ables as to what fields are in the composite key. Some tables have upto 5 fields that make up the composite key. :( Legacy system.

Thx,
David


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.