NAME
Egg::Plugin::DBIC::Transaction - Plugin that supports transaction of DBIC.
SYNOPSIS
use Egg qw/ DBIC::Transaction /;
__PACKAGE__->egg_startup(
...
.....
MODEL => [ [ DBIC => {} ] ],
);
# Object (MODEL) of MySchema is acquired.
my $model= $e->myschema_schema;
# dbh of MySchema is acquired.
my $dbh= $e->myschema_dbh;
# An arbitrary table object is acquired.
my $table= $e->myschema_table('any_table');
# MySchema is commit.
$e->myschema_commit;
# MySchema is rollback.
$e->myschema_rollback;
# After all processing is completed, MySchema is commit.
$e->myschema_commit_ok(1);
# It is a rollback after all processing is completed as for MySchema.
$e->myschema_rollback_ok(1);
DESCRIPTION
It is a plugin that adds an automation of the transaction management by Egg::Model::DBIC and some convenient accessors.
Interrupt concerning the transaction is done by the call from following Egg.
_prepare (Beginning of processing)
Begin of all Schema loaded into Egg::Model::DBIC is done. However, when AutoCommit is effective, nothing is done.
'begin' need not be done on the application side specifying it.
However, there might be a thing that the overhead cannot be disregarded according to the number of loaded Schema. As for measures concerning this, the place today is not included.
_finalize_result (End of processing)
Commit or rollback of all Schema loaded into Egg::Model::DBIC is done. However, when 'AutoCommit' is effective, nothing is done.
* [schema]_commit_ok is only effective to doing commit. 'rollback' is done whenever it is invalid.
_finalize_error (Exception is generated)
[schema]_rollback_ok is made effective.
* Because this plugin uses the method of the same to Egg::Plugin::DBI::Transaction name, it is not possible to use it at the same time.
METHODS
[schema_name]_schema
The object of Schema is returned.
schema_name is always a small letter.
It is the same as $e->model([SCHEMA_NAME]).
my $model= $e->myschema_schema;
[schema_name]_dbh
The data base handler of Schema is returned.
It is the same as $e->model([SCHEMA_NAME])->storage->dbh.
my $dbh= $e->myschema_dbh;
[schema_name]_table ( [TABLE_NAME] )
The table object that belongs to Schema is returned.
$e->model([SCHEMA_NAME])->resultset([TABLE_NAME]) or $e->model([SCHEMA_NAME]:[TABLE_NAME]) It is the same.
my $table= $e->myschema_table('hoge');
[schema_name]_begin
If the transaction of schema_name is begun and $e->debug is effective, it reports to STDERR.
* This method need not be called from the application specifying it.
[schema_name]_commit
If schema_name is 'commit' at once and $e->debug is effective, it reports to STDERR.
$e->myschema_commit;
[schema_name]_rollback
If it goes at once in the rollback of schema_name and $e->debug is effective, it reports to STDERR.
$e->myschema_rollback;
[schema_name]_commit_ok ( [BOOL] )
After all processing ends, schema_name is 'commit' if an effective value is set.
An opposite at the same time value is set in [schema_name]_rollback_ok.
$e->myschema_commit_ok(1);
[schema_name]_rollback_ok ( [BOOL] );
After all processing ends, the rollback of schema_name is done if an effective value is set.
An opposite at the same time value is set in [schema_name]_commit_ok.
$e->myschema_rollback_ok(1);
commit ( [SCHEMA_LIST] )
All [SCHEMA_LIST] is 'commit'.
$e->commit(qw/ MySchema AnySchema /);
commit_ok ( [SCHEMA_LIST] )
All 'commit_ok' of [SCHEMA_LIST] is made effective.
$e->commit_ok(qw/ MySchema AnySchema /);
rollback ( [SCHEMA_LIST] )
[SCHEMA_LIST] is done and all 'rollback' is done.
$e->rollback(qw/ MySchema AnySchema /);
rollback_ok ( [SCHEMA_LIST] )
All rollback_ok of [SCHEMA_LIST] is made effective.
$e->rollback_ok(qw/ MySchema AnySchema /);
SEE ALSO
DBIx::Class, Egg::Model::DBIC, Egg::Release,
AUTHOR
Masatoshi Mizuno <lushe@cpan.org>
COPYRIGHT
Copyright (C) 2007 by Bee Flag, Corp. <http://egg.bomcity.com/>, All Rights Reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.