On 14.08.2007 22:43 John Siracusa wrote: > On 8/14/07, Michael Lackhoff <[EMAIL PROTECTED]> wrote: >> On 14.08.2007 20:34 John Siracusa wrote: >>> On 8/14/07, Michael Lackhoff <[EMAIL PROTECTED]> wrote: >>>> $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. >>> Was there ever a commit after $obj->save but before the rollback in >>> some_helper_that_uses_db()? >> No, only the one commit at the very end. > > Assuming your have AutoCommit turned off, that's why $obj was not > saved. The rollback rolled back everything done since the last > begin_work().
Well, I didn't switch AutoCommit on or off and I didn't do a rollback myself, so the question remains why the default configuration with Apache::DBI and init_db(MyApp::DB->new) does a rollback when the database is accessed from a new db (in the helper) though this db should share the dbh with the db I do the begin_work and commit on. There was no error and I don't understand why $obj wasn't committed in the $db->commit at the very end. What exactly triggers the rollback? After all, there was no error, a (hopefully) shared dbh and a commit at the end. Why would I need a second commit before the helper? The whole point is, to have everything within one transaction. - 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