Re: ERXFetchSpecificationBatchIterator : Cannot obtain globalId for an object which is registered in an other than the databaseContext's active editingContext
Re: ERXFetchSpecificationBatchIterator : Cannot obtain globalId for an object which is registered in an other than the databaseContext's active editingContext
- Subject: Re: ERXFetchSpecificationBatchIterator : Cannot obtain globalId for an object which is registered in an other than the databaseContext's active editingContext
- From: Simon McLean <email@hidden>
- Date: Tue, 3 Mar 2009 18:45:22 +0000
Hi Lachlan -
Thanks for the tips. We did a **lot** of messing with this and simply couldn't get it to work, but we have now fixed it with a bit of a code reshuffle.
Basically, we were doing all this stuff in a thread that was fired off during willInsert(). we've now changed it so that willInsert just posts an NSNotification and another object then picks up the task. This new object actually executes exactly the same code but instead of being passed an object, it gets a primary key and re-fetches the object that needs working on itself. now it works fine.
i guess we were breaking one of the wo-commandments somewhere in there, but i've been through it over and over again and can't see where the second ec was getting created.
Simon
2009/3/2 Lachlan Deck
<email@hidden>
On 02/03/2009, at 10:46 PM, Simon McLean wrote:
I've got a bizarre error that I'm struggling to debug. Wondering if anyone
can give me a point in the right direction...?
I've got a pretty boring fetch spec, and if i call this:
NSArray batch = ec.objectsWithFetchSpecification(fs);
...I decide to introduce my usual
favorite ERXFetchSpecificationBatchIterator.
Good.
However, when I call this (in
place of the above):
ERXFetchSpecificationBatchIterator fsbi =
newERXFetchSpecificationBatchIterator(fs, ec);
I get an immediate exception:
java.lang.IllegalStateException: Cannot obtain globalId for an object which
is registered in an other than the databaseContext's active editingContext,
object: Stormking Ltd 70 er.extensions.eof.ERXEC@7e9482, databaseContext:
er.extensions.eof.ERXDatabaseContext@d6db5b, object's editingContext:
er.extensions.eof.ERXEC@7e9482, databaseContext's active editingContext:
er.extensions.eof.ERXEC@748f91
The full stack trace is as follows, which hints that it's not liking
generating the actual SQL needed for the fetch:
at
com.webobjects.eoaccess.EODatabaseContext._globalIDForObject(EODatabaseContext.java:4847)
at
Does your qualifier include objects that have references to uncommitted objects?
Does your qualifier include objects that have references to objects in different ecs (accidentally)?
Did you forget to get a local copy of some object into the new ec?
Try doing this prior to calling the constructor:
EOEntity entity = EOUtilities.entityNamed(ec, fs.entityName());
EOQualifier schemaBasedQualifier = entity.schemaBasedQualifier(fs.qualifier());
// just for fun
fs.setQualifier(schemaBasedQualifier)
Theoretically you should get the same exception because all the constructor is doing is as follows:
{
EOEntity entity = ERXEOAccessUtilities.entityNamed(ec, fetchSpecification.entityName());
<...>
this.fetchSpecification = (EOFetchSpecification) fetchSpecification.clone();
<...>
setEditingContext(ec);
<...>
EOQualifier qualifier = this.fetchSpecification.qualifier();
if (qualifier != null) {
this.fetchSpecification.setQualifier(entity.schemaBasedQualifier(qualifier));
}
}
with regards,
--
Lachlan Deck
_______________________________________________
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