-->
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: ? to generate a sequence in hibernate in DB2 4 a compositeID
PostPosted: Thu Jun 09, 2005 1:47 pm 
Newbie

Joined: Thu May 05, 2005 10:22 am
Posts: 8
hi,
can anyone help me out for generating sequence for one of the keys of a composite id..
ex:

<composite-id>
<key-Property name ="id" column="" type="">
<key-Property name ="id2" column="" type="">
<composite-id>

how to make the "id" key as a sequence in one of these composite id?

please help me out..

thanks in advance...
vinay


Top
 Profile  
 
 Post subject: Re: ? to generate a sequence in hibernate in DB2 4 a composi
PostPosted: Thu Jun 09, 2005 2:15 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
xxxx wrote:
hi,
can anyone help me out for generating sequence for one of the keys of a composite id..
ex:

<composite-id>
<key-Property name ="id" column="" type="">
<key-Property name ="id2" column="" type="">
<composite-id>

how to make the "id" key as a sequence in one of these composite id?

please help me out..

thanks in advance...
vinay


If you're generating your "id" column, it will be unique on it's own. Why do you need the composite-id ?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 10, 2005 4:58 am 
Newbie

Joined: Thu May 05, 2005 10:22 am
Posts: 8
hi ,

i got u r point ..

i have already implemented that ..
but i have to use composite id and in which one shd be autogenerated and one shd be assigned...

help me out in this issue.
thanks
vinay


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 10, 2005 5:46 am 
Beginner
Beginner

Joined: Mon Apr 11, 2005 8:37 am
Posts: 22
I had the same problem some time ago. One way to solve is to define the generated property ("id") as id and using a <properties unique="true"> element to define an additional unique set. You could reference that with the attribute property-ref in associations/collections (not in joins!).
Another way is using composite-id and writing the class to it own your own (with SQL query to get a new sequence number). A third way that might work (though I didn't get it to work) is using <sql-insert>. The SQL queries I tried with it work in Oracle but not in Hibernate - maybe somebody can figure out how it works properly.
See http://forum.hibernate.org/viewtopic.php?t=941843 and http://forum.hibernate.org/viewtopic.php?t=942144

I hope that helps ...


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.