Reputation: 9924
Does anyone have an example of the best way to begin, commit/rollback a transaction from within a CDI managed bean within a J2EE 6 container.?
I have run into a particular case where the annotated approach won't work for me (I'm calling the method from another method in the same class) and I need to set the transaction boundaries manually. I would like to know what I can do in my code that would replicate the behavior of the following annotation:
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
TIA
Upvotes: 1
Views: 388
Reputation: 246
You can write your interceptor for transaction management, then you can add this interceptor for your method. See this blog post.
In Java EE 7 we have magical (:)) @Transactional annotation for declarative transaction management as well as in EJB.
Upvotes: 1