On 14.08.2007 18:54 Perrin Harkins wrote: > On 8/14/07, John Siracusa <[EMAIL PROTECTED]> wrote: >> The simplest way to do this is to leave everything as per the >> defaults, and just use Apache::DBI. > > Note that Apache::DBI also does the automatic rollback for you, but > only if you have AutoCommit off when you connect. If you connect with > AutoCommit on, you have to handle the rollback yourself.
Perhaps I am just doing some stupid mistake but this was exactly where I started off and where it didn't work. Well, I didn't set AutoCommit explicitly, so that might have been on but I use Apache::DBI and at the beginning I had init_db { My::DB->new() } as suggested by John. But then I noticed that there was "too much" rollback that is: $db->begin_work my $obj = Products->new(db => $db); ... $obj->save; some_helper_that_uses_db(); # rollback here my $obj2 = Customers->new(db => $db); ... $obj2->save; $db->commit; When I ran this code $obj2 was saved but $obj was rolled back. I am sure it was rolled back, because I got a record_id after the save (autoincrement primary key column) but later when I wanted to redirect my app to this record I got an error that there is no record with this id. When I comment out the helper method, both objects are saved and committed. The helper isn't special but as it is it doesn't accept a 'db' argument, so my guess was that when the chain of requests with always the same db was broken, a rollback would occur. This led me to the construct with the db cached in a closure as seen in my first post. - Michael ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object