| Persistence-Entity documentation | Contained in the Persistence-Entity distribution. |
Persistence::LOB - LOBs mapping object.
Persistence::Fetchable
|
+----Persistence::LOB
use Persistence::ORM':all';
use Persistence::Entity ':all';
my $photo_entity = Persistence::Entity->new(
name => 'photo',
alias => 'ph',
primary_key => ['id'],
columns => [
sql_column(name => 'id'),
sql_column(name => 'name', unique => 1),
],
lobs => [
sql_lob(name => 'blob_content', size_column => 'doc_size'),
]
);
$entity_manager->add_entities($photo_entity);
package Photo;
use Abstract::Meta::Class ':all';
use Persistence::ORM ':all';
entity 'photo';
column 'id' => has('$.id');
column 'name' => has('$.name');
lob 'blob_content' => (attribute => has('$.image'), fetch_method => LAZY);
package EagerPhoto;
use Abstract::Meta::Class ':all';
use Persistence::ORM ':all';
entity 'photo';
column 'id' => has('$.id');
column 'name' => has('$.name');
lob 'blob_content' => (attribute => has('$.image'), fetch_method => EAGER);
my ($photo) = $entity_manager->find(photo => 'Photo', id => 10);
$photo->name('Moon');
$photo->set_image($moon_image);
$entity_manager->update($photo);
Represents a base class for object relationship.
LAZY EAGER NONE ALL ON_INSERT ON_UPDATE ON_DELETE method by ':all' tag.
Deserializes attribute value.
The Persistence::LOB 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</gt>
| Persistence-Entity documentation | Contained in the Persistence-Entity distribution. |
package Persistence::LOB; use strict; use warnings; use vars qw($VERSION); use vars qw(@EXPORT_OK %EXPORT_TAGS $VERSION); use Abstract::Meta::Class ':all'; use Persistence::Fetchable ':all'; use base qw(Exporter Persistence::Fetchable); use Carp 'confess'; $VERSION = 0.02; @EXPORT_OK = qw(LAZY EAGER); %EXPORT_TAGS = (all => \@EXPORT_OK);
has '$.attribute' => (required => 1);
has '$.orm' => (associated_class => 'Persistence::ORM', the_other_end => 'lobs');
sub initialise { my ($self) = @_; $self->install_fetch_interceptor if ($self->fetch_method eq LAZY); }
sub install_fetch_interceptor { my ($self) = @_; my $attribute = $self->attribute; $attribute->install_fetch_interceptor($self->lazy_fetch_handler($self->attribute)); }
sub deserialise_attribute { my ($self, $this, $entity_manager, $orm) = @_; my $attribute = $self->attribute; my $entity = $entity_manager->entity($orm->entity_name); my $unique_values = $orm->unique_values($this, $entity); my $lob_column = $entity->lob($attribute->column_name); my $lob = $entity->fetch_lob($lob_column->name, $unique_values, $lob_column->size_column); my $mutator = $attribute->mutator; $this->$mutator($lob); } 1; __END__
1;