This week's book giveaway is in the JDBC and Relational Databases forum.
We're giving away four copies of Resilient Oracle PL/SQL: Building Resilient Database Solutions for Continuous Operation and have Stephen Morris on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Peter Rooke
  • Himai Minh
Bartenders:
  • Piet Souris
  • Mikalai Zaikin

Practical use of transaction attributes in EJBs

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am not sure about the use of these attributes:required,mandatory,supports etc.When would you deall each of them?Pls advise

Thanks
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The transaction attributes may be specified for a method on a bean that is declared as having container-managed transaction attributes for its methods

required

This attribute indicates that the business method must be invoked in the context of a transaction. If a transaction is associated with the caller, that transaction will be associated with the method invocation. If the caller does not have an associated transaction, the container will start a new transaction prior to invoking the business method on the bean instance, and will terminate the transaction when the business method has returned. This attribute guarantees that access to multiple transactional resource managers will be made in the context of a single global transaction�and helps to ensure that data consistencies are maintained across heterogeneous systems.

mandatory

In this case, callers without a transaction context will receive a subclass of java.rmi.RemoteException, the Java Transactions API (JTA) exception javax.transaction.TransactionRequiredException. The container will not attempt to start a transactionon behalf of the caller. This is useful when failure of the business method must be correlated closely with the transactional integrity of resources associated with the caller�s transaction. A transaction attribute like Required cannot enforce this behavior. The Mandatory attribute could be used, for example, to ensure that fund transfers cannot happen independently of the success of a larger business operation in an e-commerce application.


supports

This attribute indicates that the container should allow the invocation of the business method within the transaction context of a caller. However, the method may also be called with no transaction context associated with the caller. In that case the method will be invoked in an unspecified transaction context according to the semantics we explained for the NotSupported transaction attribute. The Supports transaction attribute allows the calling client to control the transactional characteristics of the business method. This can be a powerful construct for gaining operational efficiency from a business method used in different contexts. On
the other hand, it means that required transactional behavior can be compromised by client misuse�and this can lead to data inconsistencies within an application.

Some people mistakenly believe that this attribute can be used to eliminate all interaction between the container and the transaction manager during a method invocation in which no transactional context is associated with the client.

Regardless of the container�s strategy for handling the unspecified transaction context, this is never the case; the container must still interact with the manager even in the simplest case. The efficiency is gained in the interaction with the database connections or Enterprise Integration System (EIS) adapters, which do not need to involve the XA transaction manager in their interactions
 
Here. Have a potato. I grew it in my armpit. And from my other armpit, this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic