-->
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: Hibernate Composite Key Generator
PostPosted: Thu Mar 18, 2010 12:24 am 
Newbie

Joined: Sun Feb 15, 2009 8:24 am
Posts: 9
Hi every one,

I have been working in an application where most of table have composite keys, where some part is foreign keys and some should be auto generated keys. I have looked into hibernate, it does provide very powerful ID generators for surrogate Keys, but I am unable to find a way for composite keys.

Lets have a simpler view..............

Example:

id1 - fk
id2 - fk
id3 - auto generated

Hibernate gurus should have a solution for this situation. I will be thankful for your kind help and direction.

_________________
Faisal Basra


Top
 Profile  
 
 Post subject: Re: Hibernate Composite Key Generator
PostPosted: Thu Mar 18, 2010 3:43 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
Unfortunately it is so that composite keys must always be assigned by the application. http://docs.jboss.org/hibernate/stable/ ... ompositeid


Top
 Profile  
 
 Post subject: Re: Hibernate Composite Key Generator
PostPosted: Thu Mar 18, 2010 6:12 am 
Newbie

Joined: Sun Feb 15, 2009 8:24 am
Posts: 9
Is there anyway, we can extend IdentifierGenerator and customize the identity generation mechanism??

_________________
Faisal Basra


Top
 Profile  
 
 Post subject: Re: Hibernate Composite Key Generator
PostPosted: Thu Mar 18, 2010 6:35 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
You can create custom identifier generators, but Hibernate doesn't use generators for composite keys so it will not help you. But since the id3 is auto-generated it should unique by itself. Why not simply use id3 as the id?


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.