• Post Reply Bookmark Topic Watch Topic
  • New Topic

design issue

 
Trader Joey
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For a simple distributed application, a bean needs to be designed which can return a unique transcation number each time. All transcation numbers are in serial order.
How would I go about designing this bean. Will it be an entity bean, or can I make it a stateless session bean that queries the database for the unique transaction number? Can I guarantee unique numbers if I implement the bean as a stateless session bean ?
Please advice.
Thanks
Nikhil
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd make it a stateless session bean. To guarantee unique numbers it's easy -- most databases have that feature -- Just call the appropriate feature from a SQL statement. Even if they don't it's still easy. Just get the current number, add one and update the row. Make sure that the EJB is TX_REQUIRES_NEW and all of that will happen within its own transaction.
(Note that failure outside this transaction will result in numbers being skipped).
Kyle
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!