-->
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: How to replace generator in hbm to refer to a stored proc ?
PostPosted: Wed Mar 12, 2008 7:12 pm 
Newbie

Joined: Tue Oct 04, 2005 4:08 pm
Posts: 3
Hi,

I'm currently using generator class as Sequence for my hbm files.


Code:
<generator class="sequence">
                <param name="sequence">EMP_HIBERNATE_SEQ</param>
            </generator>


Now, the project db team has decided to come up with a generic stored proc which wud return an unique index. In a nutshell, everytime I need an insert, I've to call this proc, get the sequence value and use it as a primary key.

Just wondering if there's any way to fit in this requirement in my current scenario. Any pointers will be highly appreciated.

Regards


Top
 Profile  
 
 Post subject: Re: How to replace generator in hbm to refer to a stored pro
PostPosted: Wed Mar 12, 2008 7:18 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
you might have to write your own id generator but it's not that hard. Take a look at org.hibernate.id.GUIDGenerator and I would say just copy is and put your stored procedure call in it.

Nonetheless, I am not sure if there is an easier way for this.



Farzad-


Top
 Profile  
 
 Post subject: Re: How to replace generator in hbm to refer to a stored pro
PostPosted: Wed Mar 12, 2008 7:27 pm 
Newbie

Joined: Tue Oct 04, 2005 4:08 pm
Posts: 3
farzad wrote:
you might have to write your own id generator but it's not that hard. Take a look at org.hibernate.id.GUIDGenerator and I would say just copy is and put your stored procedure call in it.

Nonetheless, I am not sure if there is an easier way for this.



Farzad-


Thanks for the input, I was taking a look at using primary key assigned by a trigger. The trigger wud internally call the proc to get the id. Not sure if it works, but I wud definitely look into ur recommendation and post my findings here...

Thanks


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.