I have a situation in which I am having a database with one sequence & trigger per table. The trigger simply sets the Primary key of a table before inserting any record using the sequence created for that table.
Using sequence as generator type doesn't work coz of the triggers i have placed. The sequence gets incremented twice
I want that primary key to be returned while saving the object.
can anyone suggest which generator type can i use..?
Well, it really sounds messy, because your sequence generator is your custom-built trigger. So, typically, either we generate our ids ourselves, or we allow a sequence or id generator on the database do it. With your solution, you're sorta blazing new ground, and it doesn't seem to fit into any of the standard strategies.
Jigar, I edited your subject line to remove the 'urgent' request. Here's what we find when posts are marked urgent:
Thank You Paul and Cameron...
First of all the reason for using triggers for id generation is... m having no. of procedures which inserts data into the tables.. its not only the application through which data is getting inserted. So, I wanted the sequences to be shared between application code and back-end procedures.
n e ways...I have applied one solution which i could think of...i.e
I have used sequence as my generator type & modified my triggers with one condition as follows:
Its simple with hibernate insert query...already there will be an id value... so no need to use the sequence again....
Any one with better solution than this would be appreciated...