Hi, I was wondering how to refresh an object (re-load from database). My obvious choice was just to call the `load' method on my object. However this doesn't update list of references to foreign objects. Consider the following simple situation: I have a user that has list of appointments (one-to-many relation).
When I create and save the user, the list of the appointments is empty - that's OK: # create user my $user = User->new(); $user->name("test"); $user->save; print @{$user->appointments}; # they are '0' nut this causes lazy loading Then I add few appointments and assign them to the user: my $app = Appointment->new(); $app->name("see the doctor"); $app->user($user); $app->save; Now I try to refresh the `user' object in order to retrieve the list of assigned appointments: $user->load; print @{$user->appointments}; # they are '0' again instead of '1' I see that RDBO makes query to the database to update the scalar properties (like `name') of the User object but it doesn't change the state of lazy loaded collection properties (like 'appointments') of the object so they can be re-fetched when accessed. I found 2 workarounds: * call load(with => 'appointments') - this will eagerly re-fetch the appointments * undef the current instance and create new instance, like this: $user = User->new(id => $user->id)->load; None of these seem elegant to me, I checked the docs of RDBO (Object, Helper, Utils) but I wasn't able to find a RDBO method that will invalidate my object so it'll be reloaded with its collection properties. Let me know if you need more info like test case, relationship configuration, database, etc. Regards, Svi ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object