Re: Mysterious EditingContext Swap
Re: Mysterious EditingContext Swap
- Subject: Re: Mysterious EditingContext Swap
- From: "Jerry W. Walker" <email@hidden>
- Date: Fri, 4 Aug 2006 07:43:24 -0400
Hi, Fabrice,
On Aug 4, 2006, at 3:07 AM, Fabrice Pipart wrote:
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)
In a word, YES.
Did you lock the child editing context for all operations on its EOs
rather than just for saveChanges? The easiest safe way to do this is
to use MultiECLockManager by registering your new EC with
MultiECLockManager as soon as you create the EC.
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
Regards,
Jerry
--
__ Jerry W. Walker,
WebObjects Developer/Instructor for High Performance Industrial
Strength Internet Enabled Systems
email@hidden
203 278-4085 office
_______________________________________________
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