BioPerl-DB
view release on metacpan or search on metacpan
lib/Bio/DB/BioSQL/BasePersistenceAdaptor.pm view on Meta::CPAN
Basically, this method will reset the object cache if any and finish
all cached statement handles and reset the statement handle cache.
Note that this method will not throw an exception even if finishing
the resources causes an error. It will issue a warning though, and
if verbose() >= 1 warnings become exceptions.
Example :
Returns : none
Args : none
=cut
sub finish{
my ($self) = @_;
if($self->{'_dbh'}) {
# finish all statement handles
foreach my $sth ($self->sth()) {
next unless ref($sth); # some statements may be disabled
eval {
$sth->finish();
};
$self->warn("error while closing statement handle: " . $@) if($@);
}
# remove the reference to the database handle
$self->{'_dbh'} = undef;
}
# reset the cache of statement handles
delete $self->{'_sth'};
# reset the object cache if any
delete $self->{'_obj_cache'} if $self->{'_obj_cache'};
# done
}
=head2 DESTROY
Title : DESTROY
Usage :
Function: We override this here to call finish().
Example :
Returns :
Args :
=cut
sub DESTROY {
my ($self) = @_;
$self->finish();
$self->SUPER::DESTROY();
}
=head1 Abstract Methods
Almost all of the following methods MUST be overridden by a
derived class. For some methods there is an implementation here
that assumes "no action" is the right thing, but for many adaptors
this won't be right. There is no way this base implementation can
make any meaningful guesses at the correct values for those.
=cut
=head2 get_persistent_slots
Title : get_persistent_slots
Usage :
Function: Get the slots of the object that map to attributes in its
respective entity in the datastore.
Slot name generally refers to a method name, but is not
required to do so, since determining the values is under
the control of get_persistent_slot_values().
This is a strictly abstract method. A derived class MUST
override it to return something meaningful.
Example :
Returns : an array of method names constituting the serializable slots
Args : the object about to be inserted or updated
=cut
sub get_persistent_slots{
shift->throw_not_implemented();
}
=head2 get_persistent_slot_values
Title : get_persistent_slot_values
Usage :
Function: Obtain the values for the slots returned by get_persistent_slots(),
in exactly that order.
The reason this method is here is that sometimes the actual
slot values need to be post-processed to yield the value
that gets actually stored in the database. E.g., slots
holding arrays will need some kind of join function
applied. Another example is if the method call needs
additional arguments. Supposedly the adaptor for a specific
interface knows exactly what to do here.
Since there is also populate_from_row() the adaptor has
full control over mapping values to a version that is
actually stored.
This is a strictly abstract method and it MUST be
overridden by a derived class.
Example :
Returns : A reference to an array of values for the persistent slots of this
object. Individual values may be undef.
Args : The object about to be serialized.
A reference to an array of foreign key objects if not retrievable
from the object itself.
=cut
( run in 0.890 second using v1.01-cache-2.11-cpan-39bf76dae61 )