Reference‎ > ‎

Execution order

During a transaction, the logic for a given persistent object is always executed in the same order. In many cases, it can be helpful to understand this order:

  1. Early actions get executed first. They can modify the object as needed, but (by definition) they don't have access to the result of the rest of the logic, since they're the first to be executed.
  2. Parent copies are next
  3. Then formulas.
  4. Then constraints
  5. Then actions
  6. Any changes that may affect child objects are then processed. If any child object is modified because it depends on the original object, we enter a new level of recursion.
  7. We then adjust any parent aggregates. In this case too, any parent object that is modified because it depends on the original object will trigger a new level of recursion.
  8. Commit actions are executed last, just before the actual commit.
  9. And finally the transaction is committed.
If an exception is thrown at any point during this process, the transaction will not be committed, but it will not be rolled back either: that is up to the code that invoked the original commit. If you are using a framework like Spring, the framework will often handle the rollback automatically.

This order has some obvious implications. For instance, constraints are executed before actions, which means that actions will not get executed if a constraint fails.