-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convenient method to wrap an unit of work into a transaction. #218
Comments
Please can I ask what the difference to something like CMT or https://jakarta.ee/specifications/transactions/2.0/apidocs/jakarta/transaction/transactional would be? Perhaps you can raise this topic on our community mailing list to potentially reach the wider Jakarta Transactions community: https://accounts.eclipse.org/mailing-list/jta-dev |
But the methods in In the Jakarta Trasanction, we could provide a general purposes API like this. public void doSomeThing() {
txOperator.doInTransaction(status -> {
wrap the unit of work in a tx.
});
// do other work outside of transation.
} |
Thank you for providing the example. Though I can understand the code snippet you shared, I am not sure if it is substantially different enough from something like:
such that it would requiring adding a new approach for transaction demarcation? Please can I ask you to elaborate a bit on what would make the new method better? Would it be to avoid the need for CDI here? Please can you also help to define a bit what TransactionStatus would look like? Is it similar to https://jakarta.ee/specifications/transactions/2.0/apidocs/jakarta/transaction/status or does it have some more functionality? |
@tomjenkinson Your code snippet can archive the purpose. What I want here is to provide a simple programmatic approach to wrap the unit of work in a tx. The transaction status in spring and Micronaut are similar. |
Thank you for reviewing the snippet. I think perhaps it would be useful to introduce this topic to the jta-dev mailing list for wider feedback from our community on this feature request? |
The JPA adds
EMF.runInTransaction
/EMF.calInTransaction
andEM.doInConnection
, and Spring also providesTransactionTemplate
andTransactionalOperator
(for reactive streams API).If possible add such a method to
UserTransaction
or create a newTransactionalOperator
for this purpose.As developers, we do not need to call
begin
andcommit
when using it.The text was updated successfully, but these errors were encountered: