I am having a model problem with a cross-model, cross-database (and apparently crossed-streams) situation.
A "Referral" object is a subclass of AbstractEncounter (subclassed in separate tables for each entity). The "referrer" relationship is only part of the Referral object, not any superclass. The "referrer" relationship is to an object that is a subclass of AppUser (vertical inheritance with qualifer of persontype = some int flag) Nothing terribly exotic about that, and I can traverse the relationship when I am creating the Referral (I can set the relationship and display the properties of the AppUser subclass (name, etc...)
The problem arises when I try display a list all the objects that are subclasses of AbstractEncounter. I can display all of the other encounter classes, but when I try to access a Referral, I get the following error:
java.lang.IllegalStateException: The object with globalID _EOIntegralKeyGlobalID[AppUser (java.lang.Integer)1044] could not be found in the database. This could be result of a referential integrity problem with the database. An empty fault could not be created because the object's class could not be determined (e.g. the GID is temporary or it is for an abstract entity).
The object does exist (with primary key 1044) and a valid persontype. If I remove the relationship from the model and call objectWithPrimaryKey for the object, I can see it, so it looks like the object is intact, but somewhere along the relationship, the Referral apparently can't tell that the user is a ClinicUser and not just an abstract AppUser (those abstract users are such slackers and never get anything done)
The other complicating issue is that I'm working with two editing contexts (to object store coordinators) One OSC is used for data that is retrieved from one database for an entire session (actually for all sessions ... things like configuration, authentication, preferences, etc...). The other editing context is changed to connect to a separate database for one of the models in the group based on the current facility being viewed. I don't know how that would affect just this relationship because I'm pretty careful about using localInstanceOf to start the graph and since the referral is retrieved from the correct editingContext, the relationship "referrer" should also use that editingContext and object store coordinator... right?
I have not been able to figure out why the Referral is getting an abstract entity (because I know the GID is not temporary... hmmm... should the primary key also include the persontype?)
Any help in tracking this down would be greatly appreciated. I have to roll out a workaround this evening and would very much like to get back to the cleaner model-based setup so I don't add too much crap that needs to be cleaned out later.
Thanks
Larry
|