Hi.
I have the following problem: I need executed some code after transaction was commited. For example:
The main problem that transaction created outside of method doSomething() but events which fired in this method should be fired after transaction.Code:class MyManager { @Transactional public void doSomething() { // Code required transaction myDao.doSomethingWihDao(); // Code MUST by executed after transaction listeners.fireEvent(); } }
I can't start new transaction here because active session locks some data (for example lazy collections in Hibernate).
I think it will be good have something like:
or something like:Code:class MyManager { @Transactional public void doSomething() { // Code required transaction myDao.doSomethingWihDao(); // Code MUST by executed after transaction fireEvent(); } @AfterTransactionCommited protected void fireEvent() { listeners.fireEvent(); } }
Code:class MyManager { @Transactional public void doSomething() { // Code required transaction myDao.doSomethingWihDao(); TransactionUtil.afterTransactionCommited(new Runnable()) { public void run() { // Code MUST by executed after transaction listeners.fireEvent(); } } } }


Reply With Quote