Questions tagged [bean-managed-transactions]

Bean-Managed Transactions (BMT) in EJB 3.1 spec allows to set transaction boundaries programmatically by obtaining a transaction and specifying `begin` and `end` of transaction in the code.

Bean-Managed Transactions (BMT) in EJB 3.1 spec allows to set transaction boundaries programmatically by obtaining a transaction and specifying begin and end of transaction in the code. When the transaction ends it should either commit or rollback. Managing beans in such a way explicitly define a control over the user transactions, independent of the container as opposed to Container-Managed Transactions (CMT) where transaction boundaries are set in a declarative way.

In a Bean-Managed transaction (BMT) code, you could explicitly mark the transaction boundaries in the session or message-driven bean. An entity bean cannot have bean-managed transactions; it must use Container-Managed Transactions (CMT) instead. Although beans with container-managed transactions require less coding, they have one limitation: when a method is executing, it can be associated with either a single transaction or no transaction at all. If this limitation will make coding your bean difficult, you should consider using bean-managed transactions.

Further reading about bean-managed transactions is from Java EE Tutorial.

24 questions
16
votes
3 answers

How does UserTransaction propagate?

I have a stateless bean with bean-managed transactions, and a method like this: @Stateless @TransactionManagement(TransactionManagementType.BEAN) public class ... { @Resource private UserTransaction ut; @EJB private…
Truong Ha
  • 10,468
  • 11
  • 40
  • 45
7
votes
1 answer

What is the relationship between BMT/CMT and an application/container-managed EntityManager?

The various partial descriptions of the subject have led me to suspect that BMT is strongly tied to an application-managed EntityManager (and the use of UserTransaction), and that CMT is strongly tied to a container-managed EntityManager. Can anyone…
6
votes
4 answers

Why do EJB beans with bean-managed transactions act as a "transaction barrier"?

A quote from the EJB 3.1 specification: 13.6.1 Bean-Managed Transaction Demarcation The container must manage client invocations to an enterprise bean instance with bean-managed transaction demarcation as follows. When a client invokes a…
Beryllium
  • 12,808
  • 10
  • 56
  • 86
3
votes
2 answers

Need of Transaction API in Java

First of all my question is What is the need of Transaction API in java ? Give me the practical example? What is the meaning for Container Managed Transaction and Bean Managed Transaction? And Difference between Declarative Transaction and…
Dilip Ganesh
  • 101
  • 1
  • 7
2
votes
1 answer

Seam-managed transactions how-to

Seam advises using an Extended persistent context in a Stateful Session Bean, in order to have Seam-managed persistence. I am not clear on whether the above advice casts any implications on the way we want to have Seam-managed transactions. This is…
Markos Fragkakis
  • 7,499
  • 18
  • 65
  • 103
1
vote
0 answers

Use of resource-manager specific transaction demarcation API in EJB 3.x

Accordinong to EJB 3.0 specification: While an instance is in a transaction, the instance must not attempt to use the resource-manager specific transaction demarcation API (e.g. it must not invoke the commit or rollback method on the…
1
vote
2 answers

Glassfish: JTA/JPA transaction not rolling back

I am running Glassfish 3.1.1 with an Oracle database and have run into an issue with transactions not rolling back, but only on one specific environment so far. The same application works as expected on other machines. However, two separate…
wrschneider
  • 17,913
  • 16
  • 96
  • 176
1
vote
0 answers

WildFly 13 migration - Only session and message-driven beans with bean-managed transaction demarcation are allowed to access UserTransaction

I have an "XAManager" class that I'm using for a JCA component inside WildFly 13. In the standalone-full.xml the resource adapter in question is defined as so: ...
Sergiu
  • 2,502
  • 6
  • 35
  • 57
1
vote
1 answer

Start/end transaction in separate EJB methods

I developed a typical enterprise application that is responsible for provisioning customer to a 3rd party system. This system has a limitation, that only one thread can work on a certain customer. So we added a simple locking mechanism that consists…
1
vote
0 answers

MQ Queue transaction not rolled back in a 2 phase transaction

I have an EJB timer (EJB 2.1) which has bean managed transaction. The timer code calls a business method which deals with 2 resources in a single transaction. One is database and other one is MQ queue server. Application server used is Websphere…
1
vote
1 answer

Transaction mixing in Java EE ( container-managed beans method called inside bean managed method )

couldn't find any kind of relevant information besides useless tutorials on the internet as well as in the specs. There's one thing that I struggle with right now, if you can please help. Here's the thing. lets say we have two EJB version 3.0 with…
1
vote
1 answer

EJB3: Why are transaction semantics and statefulness considered implementation details?

Transaction semantics and state-fullness are considered implementation details in EJB3. An implementation can decide whether to use bean or container managed transactions. It can decide the type of of container managed transaction. It can decide…
Conor
  • 2,419
  • 3
  • 19
  • 18
1
vote
1 answer

How to propagate a client-side UserTransaction into a stateless session bean using BMT

This scenario using CMT is working: Stateless session bean with CMT, one method annotated with @TransactionAttribute(TransactionAttributeType.MANDATORY). Within this method, a record is written into a RDBMS using an XA data source and plain…
Beryllium
  • 12,808
  • 10
  • 56
  • 86
1
vote
1 answer

Bean-managed transaction: transaction propagation

I'm new in EJB. I've read that one of the side effects of bean-managed transactions (BMT) is that transaction doesn't propagates if we call method of another BMT bean. But due to the third ACID property (isolating) does it mean that the second…
VB_
  • 45,112
  • 42
  • 145
  • 293
0
votes
1 answer

Some CMT and BMT doubts in EJB?

when using CMT in session beans where do we commit the transaction? With REQUIRES_NEW attribute Container creates a new transaction and the callers transaction is suspended Just get better understanding of REQUIRES_NEW , does it achieve the above…
M Sach
  • 33,416
  • 76
  • 221
  • 314
1
2