On Aug 2, 2006, at 7:05 PM, Chuck Hill wrote:
On Aug 1, 2006, at 8:50 PM, Owen McKerrow wrote:
Nope, not paraphrasing. You can see the full error message at bottom of the email.
The only time I have heard of the active editing context is for a save.
All EOF operations are serialized. The active editing context is the one that locked the object store (IIRC). You are not locking your editing contexts properly. My guess is that this is the root of your problem. Is this error consistent, or somewhat random?
Chuck
I am experiencing exactly the same problem.
Here is my context :
WebObjects 5.2.4
Mac OS 10.4.7
MySQL 4.1.18
We are using a child editing context between some pages.
BTW : is it necessary to lock a child ec after creating it? (I tried it did not change anything)
The problem appeared when we decided to use addObjectToBothSidesOfRelationship whenever we set an eo relationship.
Here is my code :
public WOComponent book() {
// create the campaign object
MediaBookingCampaign campaign = (MediaBookingCampaign) EOUtilities.createAndInsertInstance(childEC, "MediaBookingCampaign");
campaign.setAccountRelationship(media.account()); // this does an addObjectToBothSidesOfRelationship which works
campaign.setCost(new Double(totalCost));
campaign.setName(campaignName);
campaign.setMediaRelationship(media); // this does an addObjectToBothSidesOfRelationship which works
// create the mediaBookings objects
processBooking(campaign, null, null);
// save the syncBookings
childEC.saveChanges();
session().defaultEditingContext().saveChanges();
return pageWithName("com.easyshadow.webui.booking.MediaBookingsComponent");
}
/**
* create all the necessary mediaBookings objects for the MediaBookingCampaign
*/
private void processBooking(MediaBookingCampaign mediaBookingCampaign) {
Playlist playlist;
MediaBooking mediaBooking;
for (int i = 0; i < selectedPlaylists.count(); i++) {
playlist = (Playlist) selectedPlaylists.objectAtIndex(i);
// if there is some playtimes, create the mediaBookings
if (!playtimes.equals("0")) {
mediaBooking = (MediaBooking) EOUtilities.createAndInsertInstance(childEC, "MediaBooking");
mediaBooking.setMediaRelationship(media);
mediaBooking.setMediaBookingCampaignRelationship(mediaBookingCampaign);
mediaBooking.setPlaylistRelationship(playlist);
mediaBooking.setBookingDate(new Long(new GregorianCalendar(TimeZone.getTimeZone("GMT")).getTimeInMillis()));
}
}
}
Before saving the default editing context (in book() ), I checked that in it :
- all inserted objects (both the MediaBooking and the MediaBookingCampaign are here) are in the default editing context
- all changed objects (both the MediaBooking and the MediaBookingCampaign are here) are in the default editing context
But I end up with a :
java.lang.IllegalStateException: Cannot obtain globalId for an object which is registered in an other than the databaseContext's active editingContext
in com.webobjects.eoaccess.EODatabaseContext._globalIDForObject
It seems I have a MediaBooking in the childEc !
Where does that one come from ???
Thanks to anyone who could help !
Fabrice