aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes need generate unique number and it should not skip at any situation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "need generate unique number and it should not skip at any situation" Watch "need generate unique number and it should not skip at any situation" New topic
Author

need generate unique number and it should not skip at any situation

Ravi Kommuri
Greenhorn

Joined: Dec 20, 2013
Posts: 13
Hi All,

we have a customer requirement , need to generate a unique number(configurable) and it should not skip at any situation.


we have about 3- 4 modules where we need to generate.
and update in some xyz table column each time

we are doing this as below approach.

we generate that number in separate transaction and that too in end of the business logic and then move to success page.

but recently it got skipped due to time out error during updating .... the db usage is huge at some time and multi user doing operation which intern generate multiple number of this time.

but as DB is not responded and complete transaction is roll out and this number got skipped...


so any once can suggest possible approach to achieve this.


Jelle Klap
Bartender

Joined: Mar 10, 2008
Posts: 1778
    
    7

The only reliable way I can think of would be to use a sequence table that you query with a select for update at the start of the transaction, use the value in some other update/insert statements, then increment and update the value in the sequence table - all within the same transaction. It will be a performance nightmare, though, because of the exclusive lock.


Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: need generate unique number and it should not skip at any situation