• 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Question on container-managed transaction Demarcation

Ranch Hand
Posts: 634
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Source:EJB 3.1 Specification

4.3.3 The SessionContext Interface

One of the methods of SessionContext interface is :

The setRollbackOnly method allows the instance to mark the current transaction such
that the only outcome of the transaction is a rollback. Only instances of a session bean with
container-managed transaction demarcation can use this method.

What does "container-managed transaction demarcation " means here ?
Creator of Enthuware JWS+ V6
Posts: 3348
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Transactions are either managed by the Container: they are having a so called container-managed transaction demarcation, or
transactions are managed programmatically by the developer: they are having a bean-managed transaction demarcation.

From the EJB-specs:

13.3.1 Bean-Managed Versus Container-Managed Transaction Demarcation
When designing an enterprise bean, the developer must decide whether the enterprise bean will demarcate transactions programmatically in the business methods (bean-managed transaction demarcation), or whether the transaction demarcation is to be performed by the container based on the transaction attributes specified in metadata annotations or in the deployment descriptor

Coming back to the SessionContext method setRollbackOnly() can only be used if your Session bean has:
- the annotation @TransactionManagement(TransactionManagementType.CONTAINER) on the EJB class, or
- has no annotation (because CONTAINER is the default)

Consequently the method setRollbackOnly() cannot be used if the Session Bean has the annotation @TransactionManagement(TransactionManagementType.BEAN) on the EJB class.

Mohit G Gupta
Ranch Hand
Posts: 634
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Frits
Morning came much too soon and it brought along a friend named Margarita Hangover, and a tiny ad.
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic