I've run into a use case for my application that is causing objects to be lost 
when the connection to the db is reset (intentionally based on the users 
selection of what the "current facility" is in their session). I am trying to 
clean up some of the older parts of the application to fix some errors with 
objects that were fetched into the ec before it was reset looking for the old 
object store connections. 

So far, the cleanup appears to be going well and solving the problem. 
Forgive me if this is an obvious or trivial, but I wanted to bounce this off 
the list to see if anybody sees any obvious flaws in this general approach or 
if someone has a cleaner (more WOnderful) suggestion.

In the session, I have a commonEC and a facilityEC. The commonEC uses the 
EOObjectStoreCoordinator that is used for all sessions (what you get by just 
calling ERXEC.newEditingContext()) and the facilityEC uses a new 
EOObjectStoreCoordinator and connects using:

ERXEOAccessUtilities.closeDatabaseConnections(facilityOSC);
EOUtilities.connectWithModelNamed(facilityEC, COMMON_MODEL_NAME, null); #no 
change in connection dictionary
EOUtilities.connectWithModelNamed(facilityEC, FACILITY_MODEL_NAME, cdict); # 
change to location of db


Now, if I'm deliberate in using ERXEC.newEditingContext() for common objects 
(like user, permissions, UI support...) and 
ERXEC.newEditingContext(facilityOSC) for current facility specific things, I 
should be fine ... right? 

One question that troubles me is how do I get rid of all the objects that are 
in the facilityOSC? If I call invalidateAllObjects() everything turns into a 
fault, but I don't want a fault for anything in the facilityEC because an 
object in a different database may have the same global id as one that was 
fetched earlier (before the reconnection to the different database)
My concern is that a facility has patients who have treatments .... and I don't 
want a patient fault to cause the ec to look for a global id when connected to 
a new database. 
If I refault the facility, will that forget all the related objects or will 
they all turn to faults?



Larry Mills-Gahl
[email protected]



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to