'loha folks,
short: How do i migrate data, fetched from a temporary table, from one editing context into another?
Details below...
The situation is as follows:
First, data are inserted into a temporary table (Oracle 8i) by using a stored procedure. Then, in the same procedure, these data are fetched from the temporary table into the user sessions editing context.
Up to now, I've used ReportMill for generating reports based on this temporary data. This happens in the same editing context and does not cause any problems.
But since ReportMill isn't fun to work with at all, I've decided to implement my own web-based reporting tool. This one generates the report in its own thread and uses its own editing context (no shared editing context). It works by simply processing a object graph and invoking all methods (attributes, relationships) using reflection (java.lang.reflect) based on some root objects that have to be passed to the reporting tool.
Since the data source is a temporary table in this case, the data objects can't be inserted into another editing context, because an exception, telling that these objects can't be registered in two editing contexts, would be (and is) shown.
So, I've tried to migrate them into a new editing context by faulting for the objects global id in the original editing context. This basically works, but the migrated data, namely all attribute values, relationships etc. are NULL. For permanent tables, this way of migration works well (code below):
EOEditingContext oldEditingContext = enterpriseObject.editingContext(); EOGlobalID globalID = oldEditingContext.globalIDForObject(enterpriseObject); result = newEditingContext.faultForGlobalID(globalID, newEditingContext);
Another trial was, to "copy" all objects, telling the old editing context to forget about them and inserting the copy into the new editing context (see code below).
EOEnterpriseObject result = enterpriseObject; enterpriseObject.editingContext().forgetObject(enterpriseObject);
newEditingContext.insertObject(result);
But this does not work either. When trying to get some attributes value or another object reachable over a relationship, still null is returned.
BUT, when adding e.g. a system out BEFORE migrating the data, accessing some value (e.g. the primary key), the migrated data are not null (in fact, now all attributes and relationships and so on are accessible and do return the correct value).
Since I'm treating this phenomenon for hours and don't see the light, I finally have to ask for help. Any hints would be appreciated.
Regards
Andri von Allmen
|