Cannot obtain globalId for an object which is not registered in any editingContext
Cannot obtain globalId for an object which is not registered in any editingContext
- Subject: Cannot obtain globalId for an object which is not registered in any editingContext
- From: Andrew Kinnie <email@hidden>
- Date: Sun, 26 Dec 2004 13:02:11 -0500
Greetings:
I am trying to redesign the site that was causing problems. I previously tried to add a new table to the database that was underlying a working site (well, a copy of the database, on a copy of the site) with the new table having all of the characteristics of another table (each table was for a specific location for the business, now that there was more than one). This didn't work. (well at least trying to add new rows to the database didn't work. . . apparently EOF has trouble figuring out that Entity_one of type MyEntity is a different thing than Entity_two which is also of type MyEntity, even though they point to different tables in the database.
I have taken people's advice, and killed the extra table, and have instead added a column to the exiting table to represent the different location. However, even though I dropped the tables, and then recreated fresh new ones via EOModeler "execute SQL" when I try to add a new object to this table, I get an exception
"Cannot obtain globalId for an object which is not registered in any editingContext"
which in the run log shows up as follows:
newBooking is: {values = {eventDate = <com.webobjects.foundation.NSKeyValueCoding$Null>; clubName = <com.webobjects.foundation.NSKeyValueCoding$Null>; agent = "null"; performance = "null"; }; this = "<Booking 58d74b <EOTemporaryGlobalID: 0 0 10 0 1 2 0 0 -3 93 1 0 0 0 1 1 16 125 -73 -67 -81 -67 -85 -92>>"; }
newBooking eventDate is: null
[2004-12-26 12:47:49 EST] <WorkerThread5> === Begin Internal Transaction
[2004-12-26 12:47:49 EST] <WorkerThread5> finding primary key value for BOOKING
[2004-12-26 12:47:49 EST] <WorkerThread5> evaluateExpression: <com.webobjects.jdbcadaptor.OpenBasePlugIn$OpenBaseExpression: "SELECT PK FROM EO_PK_TABLE WHERE NAME = 'BOOKING' FOR UPDATE">
[2004-12-26 12:47:49 EST] <WorkerThread5> fetch canceled
[2004-12-26 12:47:49 EST] <WorkerThread5> 1 row(s) processed
[2004-12-26 12:47:49 EST] <WorkerThread5> updating primary key value for BOOKING
[2004-12-26 12:47:49 EST] <WorkerThread5> evaluateExpression: <com.webobjects.jdbcadaptor.OpenBasePlugIn$OpenBaseExpression: "UPDATE EO_PK_TABLE SET PK = 3 WHERE NAME = 'BOOKING' AND PK = 2">
[2004-12-26 12:47:49 EST] <WorkerThread5> java.lang.IllegalStateException: Cannot obtain globalId for an object which is not registered in any editingContext, object: {values = {eventDate = 2005-01-01 05:00:00 Etc/GMT; clubName = <com.webobjects.foundation.NSKeyValueCoding$Null>; agent = "null"; performance = "<Performance 14d739 _EOIntegralKeyGlobalID[Performance (java.lang.Integer)1]>"; }; this = "<Booking 3503e5 [Gid Not Found]>"; }, databaseContext: com.webobjects.eoaccess.EODatabaseContext@c5eb8a, object's editingContext: null, databaseContext's active editingContext: com.webobjects.eocontrol.EOEditingContext@267610
I don't understand why it's not finding the object in the editing context. The code I am using is this:
public WOComponent submitNewBooking()
{
formComplete = false;
errorMsg = "";
// ec is a class variable representing the default editing context. it is used all over the place, without problems.
Session s = (Session)session();
if(newBooking.eventDate() != null) {
if(selectedPerformance == null){
System.out.println("No performance selected");
errorMsg = errorMsg + "Please select a Performance for the event<br>";
formComplete = false;
ec.revert();
} else {
if(! editingObject) {
newBooking = (Booking)EOUtilities.createAndInsertInstance(ec, "Booking");
ec.insertObject(newBooking);
System.out.println("newBooking is: " + newBooking);
if(clubNumber == 1){
newBooking.setClubName("First Club Name");
s.bookingList.addObject(newBooking);
s.sortObjects(s.bookingList);
} else {
newBooking.setClubName("Second Club Name");
s.secondBookingList.addObject(newBooking);
s.sortObjects(s.secondBookingList);
}
}
if(startTimeMinutes == null) {
startTimeMinutes = new Integer(0);
}
formComplete = true;
"PM")){
startTimeHours = new Integer(startTimeHours.intValue() + 12);
}
System.out.println("newBooking eventDate is: " + newBooking.eventDate());
ec.saveChanges();
showBookingEntryForm = false;
newBooking = new Booking();
return null;
}
} else {
errorMsg = errorMsg + "PLEASE give me a date for the event<br>";
formComplete = false;
ec.revert();
}
return null;
}
I don't see what else I need to do. I am wondering if there is something about the executeSQL in EOModeler that did something weird. I looked at the EO_PK table and there seems to be 3 rows. One each for user (me), the test performance, and one for the booking. The PKs for each are 1 for the first two, and 3 for the Booking table.
There is clearly something I am not understanding about this under the hood stuff. I made sure the extra column in the Booking table accepts null input.
If anyone can help I'd appreciate it.
Andrew
PS: I am using Mac OS X client 10.3.7 and WO 5.2 with Openbase 8
_______________________________________________
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