Hi,
I am trying to figure out a way to generate sequential values. The db2 version we are using does not support sequences.
An example of what I need to do is to generate check numbers. The check class already has a primary key that uses the identity generator. I wanted to create a method like: public static Long getNextCheckNumber(); I need to be able to set the starting check number of the sequence. I will also need this type of functionality for journal number etc. I was thinking of using a table with one record in it with a column that holds the last value used for each sequence. Then I wanted to start a transaction, lock the record, fetch the value, inc by 1, save the new value, unlock the record, end the transaction, then return the value. The application is a web application using hibernate. This application may be ran on multiple app servers connectected to the same db.
Has someone solved the above problem already using hibernate? I am sure others out there have had to generate check numbers. I would appreciate your experiance. Could someone provide me with some direction (code is very helpful).
Thanks,
Rich
|