public class SimpleTransactionManager extends Object
Simple transaction manager provides a simple mechanism to manage transactions
in test code through the UserTransaction object. To construct the
transaction manager use:
SimpleTransactionManager manager = new SimpleTransactionManager(
new DefaultUserTransactionFactory());
Next, add resources to manage using addResource(TransactionResource):
manager.addResource(jpaTester.getJpaBuilder());
As you can see from the above, JpaBuilder is a resource that can be
used so this mechanism can be used with JPA testing.
The next step is to manage transactions using the standard
UserTransaction APIs:
UserTransaction transaction = manager.getTransaction();
transaction.begin();
... do work...
transaction.commit();
| Constructor and Description |
|---|
SimpleTransactionManager(UserTransactionFactory aFactory)
Constructs the transaction manager.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addResource(TransactionResource aResource)
Adds a resource to manage.
|
UserTransaction |
getTransaction()
Gets the user transaction.
|
public SimpleTransactionManager(UserTransactionFactory aFactory)
aFactory - Factory to create transactions with.public void addResource(TransactionResource aResource)
aResource - Resource.public UserTransaction getTransaction()
Copyright © 2025. All rights reserved.