| Persistence-Entity documentation | Contained in the Persistence-Entity distribution. |
Persistence::ValueGenerator::SequenceGenerator - Unique value generator based on database sequence
Persistence::ValueGenerator
|
+----Persistence::ValueGenerator::SequenceGenerator
use Persistence::ValueGenerator::SequenceGenerator;
my $generator = Persistence::ValueGenerator::SequenceGenerator->new(
entity_manager_name => $entity_manager_name,
name => 'pk_generator',
sequence_name => 'cust_seq',
allocation_size => 1,
);
$generator->nextval;
or
use Persistence::ValueGenerator::SequenceGenerator ':all';
my $generator = sequence_generator 'pk_generator' => (
entity_manager_name => $entity_manager_name,
sequence_name => 'cust_seq',
allocation_size => 1,
)
Represents sequence generator that uses database sequcnce.
sequence_generator by ':all' tag.
Returns next value for the instance generator
Creates a new instance of Persistence::ValueGenerator::TableGenerator
The Persistence::ValueGenerator::SequenceGenerator module is free software. You may distribute under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file.
Adrian Witas, adrian@webapp.strefa.pl
| Persistence-Entity documentation | Contained in the Persistence-Entity distribution. |
package Persistence::ValueGenerator::SequenceGenerator; use strict; use warnings; use vars qw(@EXPORT_OK %EXPORT_TAGS $VERSION); use base qw (Exporter Persistence::ValueGenerator); use Abstract::Meta::Class ':all'; @EXPORT_OK = qw(sequence_generator); %EXPORT_TAGS = (all => \@EXPORT_OK); $VERSION = 0.02;
has '$.sequence_name' => (required => 1);
sub retrieve_next_value { my ($self) = @_; my $entity_manager = $self->entity_manager; my $connection = $entity_manager->connection; $connection->sequence_value($self->sequence_name); }
sub sequence_generator { my $name = shift; __PACKAGE__->new(@_, name => $name); } 1; __END__
1;