Update database so that we can manage nested transactions

the code [ connection setAutoCommit true ] was causing issues when using nested transactions. 
it now update autoCommit to previous value and only when needed. 

remark : in the "def transaction" code getAutoCommit is outside of the try block, it could potentially throw an exception at lease when connection object is null (other cases depending on the specific implementation used, but I'm not an expert). I could use a double try just in case.