Re: Migrating Data from a temporary table into another editing context
Re: Migrating Data from a temporary table into another editing context
- Subject: Re: Migrating Data from a temporary table into another editing context
- From: Chuck Hill <email@hidden>
- Date: Wed, 29 Apr 2009 10:09:51 -0700
Hi Andri,
On Apr 29, 2009, at 5:19 AM, Andri vonAllmen wrote:
'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.
It sounds to me like you were doing something wrong. Why not just
fetch the data into the thread's EC instead of the session's?
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.
I don't understand why that should be.
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.
Because you told it to forget the data!
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).
That is because it then faults in the data.
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.
I'd try and fetch directly into the thread's EC. Failing that,
Practical WebObjects has code to copy a graph of objects.
Chuck
--
Chuck Hill Senior Consultant / VP Development
Come to WOWODC'09 in San Fran this June!
http://www.wocommunity.org/wowodc09/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden