Application code control of transactions

Jun 7, 2012 at 4:19 PM

We need to clarify transaction handling within NakedObjects.MVC.

As you would expect changes to the database(s) within a single MVC request are done within a transaction and if any update fails the whole transaction fails and is not committed.

However just throwing an exception or doing a Container.RaiseError() within domain code does not abort the current transaction and so any changes will be committed.

We need to give application programmers a way to abort the current transaction from the application domain code. Currently you can do this but you need to call into the framework code (ie NakedObjectsContext.ObjectPersistor.AbortTransaction()). 

So what we will do in the next release is

  1. Add a new method to the Container eg 'AbortCurrentTransaction' to give the domain code the ability to manually abort a transaction
  2. Make this behaviour configurable on startup. Such that optionally exceptions thrown from the domain code will automatically abort the current transaction.

thanks Jacques for the heads-up