• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Paul: EJB Transaction types

 
Paul Croarkin
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of the six EJB transaction types (Required, RequiresNew, Supports, NotSupported, Mandatory, Never), Required and RequiresNew seem pretty easy to understand, but some of the others are not so clear.

Supports seems to equate to "I don't care" and could be dangerous.

NotSupported and Never also seem like they should be avoided. Would it really hurt to use Required on RequiresNew instead?

Couldn't you use RequiresNew anywhere that you would use Mandatory and avoid the possibility of throwing a TransactionRequiredException?

thanks,
Paul
 
Kai Witte
Ranch Hand
Posts: 356
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,

I append a question about NotSupported:

Does it let a transaction "sleep", so that it can be woken up by a Supports, Required or Mandatory? Would the original transaction of the caller be woken up by any of the three?



Kai
 
Paul Sanghera
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul:
It always comes down to the basics: the business logic you are using to implement the business requirements of the application, and partly how you are implementing it. For example consider the situation where a transaction is implemented in more than one methods :-). In other words, you have a method that does something which is always a part of a transaction (that has already started) and never a full transaction by itself. Mandatory is the only option you have.

Exercise: Think of an example :-). Hint: Transactions often have more than one steps.
(I guess the teacher inside is taking over me).
Thank you for a very good and thoughtful question, Paul.

Paul

Originally posted by Paul Croarkin:
Of the six EJB transaction types (Required, RequiresNew, Supports, NotSupported, Mandatory, Never), Required and RequiresNew seem pretty easy to understand, but some of the others are not so clear.

Supports seems to equate to "I don't care" and could be dangerous.

NotSupported and Never also seem like they should be avoided. Would it really hurt to use Required on RequiresNew instead?

Couldn't you use RequiresNew anywhere that you would use Mandatory and avoid the possibility of throwing a TransactionRequiredException?

thanks,
Paul

[ July 28, 2005: Message edited by: Paul Sanghera ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic