line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Persistence::ValueGenerator::SequenceGenerator; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
25652
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
73
|
|
4
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
84
|
|
5
|
2
|
|
|
2
|
|
10
|
use vars qw(@EXPORT_OK %EXPORT_TAGS $VERSION); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
145
|
|
6
|
2
|
|
|
2
|
|
11
|
use base qw (Exporter Persistence::ValueGenerator); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
767
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
17
|
use Abstract::Meta::Class ':all'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
665
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
@EXPORT_OK = qw(sequence_generator); |
11
|
|
|
|
|
|
|
%EXPORT_TAGS = (all => \@EXPORT_OK); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
$VERSION = 0.02; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 NAME |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Persistence::ValueGenerator::SequenceGenerator - Unique value generator based on database sequence |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 CLASS HIERARCHY |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
Persistence::ValueGenerator |
22
|
|
|
|
|
|
|
| |
23
|
|
|
|
|
|
|
+----Persistence::ValueGenerator::SequenceGenerator |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 SYNOPSIS |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
use Persistence::ValueGenerator::SequenceGenerator; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my $generator = Persistence::ValueGenerator::SequenceGenerator->new( |
30
|
|
|
|
|
|
|
entity_manager_name => $entity_manager_name, |
31
|
|
|
|
|
|
|
name => 'pk_generator', |
32
|
|
|
|
|
|
|
sequence_name => 'cust_seq', |
33
|
|
|
|
|
|
|
allocation_size => 1, |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
$generator->nextval; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
or |
39
|
|
|
|
|
|
|
use Persistence::ValueGenerator::SequenceGenerator ':all'; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my $generator = sequence_generator 'pk_generator' => ( |
42
|
|
|
|
|
|
|
entity_manager_name => $entity_manager_name, |
43
|
|
|
|
|
|
|
sequence_name => 'cust_seq', |
44
|
|
|
|
|
|
|
allocation_size => 1, |
45
|
|
|
|
|
|
|
) |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 DESCRIPTION |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Represents sequence generator that uses database sequcnce. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 EXPORT |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sequence_generator by ':all' tag. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 ATTRIBUTES |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=over |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=item sequence_name |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=cut |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
has '$.sequence_name' => (required => 1); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=back |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 METHODS |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=over |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=item retrieve_next_value |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Returns next value for the instance generator |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=cut |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub retrieve_next_value { |
78
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
79
|
0
|
|
|
|
|
|
my $entity_manager = $self->entity_manager; |
80
|
0
|
|
|
|
|
|
my $connection = $entity_manager->connection; |
81
|
0
|
|
|
|
|
|
$connection->sequence_value($self->sequence_name); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=item sequence_generator |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Creates a new instance of Persistence::ValueGenerator::TableGenerator |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=cut |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub sequence_generator { |
92
|
0
|
|
|
0
|
1
|
|
my $name = shift; |
93
|
0
|
|
|
|
|
|
__PACKAGE__->new(@_, name => $name); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
1; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
__END__ |