<cffunction name="SaveWithTransaction" access="public" returntype="any" output="false" hint="I take a photo object and persist it (using a database transaction)."> <!--- Define arguments. ---> <cfargument name="Photo" type="any" required="true" hint="I am the photo object to be persisted." /> <!--- Wrap the whole interaction in a transaction. ---> <cftransaction action="begin"> <cftry> <!--- Because the functionality for saving already exists, let's just turn around and call our existing Save() method (that works in a non- transaction way). Return the object that is passed back from our Save() method. ---> <cfreturn THIS.Save( ARGUMENTS.Photo ) /> <!--- Catch any errors. ---> <cfcatch> <!--- Roll back transaction. ---> <cftransaction action="rollback" /> <!--- Rethrow error. ---> <cfrethrow /> </cfcatch> </cftry> </cftransaction> </cffunction>