[CDBI] objects not updated in memory

Perrin Harkins perrin at elem.com
Wed Oct 26 15:18:22 BST 2005


On Wed, 2005-10-26 at 11:30 +0200, Patrik Wallstrom wrote:
> I have some classes which references objects which use Class::DBI,
> more exactly, a session object which store a user object.

Don't put Class::DBI objects in a session.  If you need to store
something in the session, store the ID.

>     my $user_id = $self->user->id;
>     $self->{'_user'}->remove_from_object_index();

What's that?  Is it the same as $self->user()?  This is pretty confusing
code.

If you restored this User object from the session, it's not in the
object index.

> But ... even if I disable the Live object cache, I never get the
> updated user from the database, and I can even see the query from the
> database (and I update some records between reads).
> 
> Any clues on what is going on?

My guess would be some kind of scoping problem is tricking you about
which object you are actually looking at.  Trying to write a simple test
case for this might help you find the problem.  Or, it could be
something to do with isolation levels in your database and visibility of
committed data.  What database are you using?

- Perrin





More information about the ClassDBI mailing list