CommitContext Use


I am developing a billing application. The billing engine code (implemented on the service bean level) performs several insert and update statements on physical tables when the user runs billing.
I want to make sure that all these transactions are either committed or roll-backed together. I am using CommitContext and passing the entity names accordingly (please check attached file showing one example method used in the billing generation engine).
This is working fine so far, however, there are some flags that I need to update when the work is done, and these updates have to be part of the same commit context. The “addInstanceToCommit” method only adds new instances to the passed entity. What is the best way to include update statements in the commit context?

Many thanks for your usual support.


generateCharges.txt (2.9K)

Hi Shady,

DataManager always creates a new transaction inside, so your enclosing transaction doesn’t affect it. You shouldn’t mix low-level transaction management with higher-level operations through DataManager - use either transactions + EntityManager OR DataManager without transaction management.

When you need something more than just CRUD operations on entities, use EntityManager. See examples here.

Thank You for the clarification.