Hi,
I have a transaction which simply updates an element in table A. However, a number of other related elements in another table B needs to be updated whenever the element in table A is updated.
I achieve this now by doing the following:
Code:
currentSession.beginTransaction();
manager.update(currentNode);
currentSession.getTransaction().commit();
currentSession.beginTransaction();
//This is a call to a native SQL query.
manager.executeKeywordChanged(currentNode);
currentSession.getTransaction().commit();
1. If the first block fails - everything is fine. No damage done.
2. If the second block fails - then suddenly the element in table A is updated but the related elements remain unchanged.
The main issue is that if i put both the update() and executeKeywordChanged() calls in the same transaction block, then executeKeywordChanged() will be flushed immediately when i invoke the method (no matter what) as it is a native SQL query. The save() will not be flushed before commit() is invoked.
The dream scenario here would be as follows, where update() and executeKeywordChanged() would be flushed sequentially on commit().
Code:
currentSession.beginTransaction();
manager.update(currentNode);
manager.executeKeywordChanged(currentNode);
currentSession.getTransaction().commit();
However, this seems not to be the case. Any others with experience on this?
[/code]