-->
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: Using a generator with composite-id
PostPosted: Fri Nov 18, 2005 8:39 am 
Newbie

Joined: Fri Nov 18, 2005 8:35 am
Posts: 2
Hello,

I have composite id, made up of two properties. One of which is a foreign key in the table, and the other which isn't.

<composite-id name="id" class="persistence.MatchExpulsionsId">
<key-property name="matchId" type="int">
<column name="MATCH_ID" />
</key-property>
<key-property name="expulsionNo" type="int">
<column name="EXPULSION_NO" />
</key-property>
</composite-id>

So, here it is easy to have MATCH_ID, because it is a foreign key from another relation.

I would like to have EXPULSION_NO automatically generated (increment)...so that it now looks like:

<composite-id name="id" class="persistence.MatchExpulsionsId">
<key-property name="matchId" type="int">
<column name="MATCH_ID" />
</key-property>
<key-property name="expulsionNo" type="int">
<column name="EXPULSION_NO" />
<generator class="increment" />
</key-property>
</composite-id>

Is there anyway to achieve this, or is there a workaround?

Many thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 18, 2005 11:25 am 
Expert
Expert

Joined: Wed Apr 06, 2005 5:03 pm
Posts: 273
Location: Salt Lake City, Utah, USA
This FAQ might help you:

http://www.hibernate.org/117.html#A35

_________________
nathan


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 18, 2005 11:53 am 
Newbie

Joined: Fri Nov 18, 2005 8:35 am
Posts: 2
That did it...thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 22, 2005 8:01 am 
Newbie

Joined: Thu Dec 22, 2005 7:57 am
Posts: 1
i am also finding the same code ,
Would any one send me the source code for the same ?

Thanks
Ashwani


Top
 Profile  
 
 Post subject: Generator in composite-id
PostPosted: Tue Feb 13, 2007 8:46 am 
Newbie

Joined: Tue Feb 13, 2007 8:39 am
Posts: 1
Hi Dreamliner,
You said that you solved this problem of having an increment class generator in composite-id. Could you please send the code for the same? I'm facing the same problem.

Thanks in advance.


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.