Re: Deleting an object on the other side of a has_a

[prev] [thread] [next] [Date index for 2004/09/01]

From: Perrin Harkins
Subject: Re: Deleting an object on the other side of a has_a
Date: 15:32 on 01 Sep 2004
On Wed, 2004-09-01 at 06:02, Peter Pimley wrote:
> sub remove_b {
>     my $self = shift;  #  so $self is an object of ClassA
>     my $b = $self->my_b;
>     $self->my_b(undef);  #  there is no documentation for this, but it 
> seems to do the correct thing to the database
>     $b->delete;
> }

I would probably commit that update before doing the $b->delete. 
Otherwise, you are potentially creating a referential integrity problem.

You can also set up a cascading delete here if you want to, using a
trigger.  Then you wouldn't need to have this special method.

> The problem I have is that a 
> seperate process accessing the same database does not notice the change, 
> and seems to keep the old ClassB object in memory.

Do you have a copy of the ClassA instance in memory in this other
server?  Class::DBI doesn't attempt to synchronize your in-memory
objects.  Which database are you using?  Something with transactions?

- Perrin

(message missing)

Deleting an object on the other side of a has_a
Peter Pimley 10:02 on 01 Sep 2004

Re: Deleting an object on the other side of a has_a
Perrin Harkins 16:09 on 01 Sep 2004

Re: Deleting an object on the other side of a has_a
Perrin Harkins 15:32 on 01 Sep 2004

Re: Deleting an object on the other side of a has_a
Perrin Harkins 16:33 on 01 Sep 2004

Re: Deleting an object on the other side of a has_a
Perrin Harkins 17:03 on 01 Sep 2004

Re: Deleting an object on the other side of a has_a
Perrin Harkins 16:42 on 01 Sep 2004

Re: Deleting an object on the other side of a has_a
Perrin Harkins 15:06 on 02 Sep 2004

Generated at 11:34 on 01 Dec 2004 by mariachi v0.52