The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Persistence::ValueGenerator - Unqiue value generator.

SYNOPSIS

   use Persistence::ValueGenerator::TableGenerator;

    my $generator = Persistence::ValueGenerator::TableGenerator->new(
        entity_manager           => $entity_manager_name,
        name                     => 'empno_generator',
        table                    => 'seq_generator',
        primary_key_column_name  => 'pk_column',
        primary_key_column_value => 'empno',
        value_column             => 'value_column',
        allocation_size          =>  5,
    );

    my $entity = Persistence::Entity->new(
        name                  => 'emp',
        unique_expression     => 'empno',
        primary_key           => ['empno'],
        columns               => [
            sql_column(name => 'ename'),
            sql_column(name => 'empno'),
            sql_column(name => 'deptno')
        ],
        value_generators => {empno => 'empno_generator'},
    );
    # or
    # $entity->add_value_generators(empno => 'empno_generator');

    $entity_manager->add_entities($entity);

DESCRIPTION

Abstract class for value generator's class.

EXPORT

None

ATTRIBUTES

name

Defines the name of the Persistence::ValueGenerator::TableGenerator instance and is the name referenced in the

allocation_size

Defined how much the counter will be incremented when entity queries the table for a new value, This feature is to cache blocks so that it doesn't have to go to the database every time it needs a new ID.

_cached_seq

Stores counter for current seq and allocation_size

entity_manager_name

Entity manager name

_entity_manager

Caches entity manager instance.

METHODS

initialise
generator

Returns generator instance, takes table generator name.

nextval

Returns next value for the instance generator

retrieve_next_value

Abstract method retrieve_next_value

has_cached_seq

Return true if objects holds cached_seq.

entity_manager

Returns entity manager.

SEE ALSO

Persistence::ValueGenerator::TableGenerator Persistence::ValueGenerator::SequenceGenerator

COPYRIGHT AND LICENSE

The Persistence::ValueGenerator 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.

AUTHOR

Adrian Witas, adrian@webapp.strefa.pl