• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Strange EO issue
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Strange EO issue


  • Subject: Re: Strange EO issue
  • From: David LeBer <email@hidden>
  • Date: Tue, 14 Dec 2004 16:16:16 -0500

On Dec 14, 2004, at 3:59 PM, Andrew Kinnie wrote:

In my never ending quest to add basic functionality to an existing site, I seem to now be having EO issues.

My database has a table called BOOKING which has as its Entity name "Booking" and class "Booking" and this has been the case since the site was first deployed 2 years ago.

We added a new location to the company, and as part of this, I added a table to the EOModel and executed the SQL to create the table in the database. The new table is called GENEVA_BOOKING, the entity is called GenevaBooking, and the class is still Booking. I added a column to a table on the site to allow administrative users to add bookings for the new location.

I don't think this is going to work for you. How does EOF know which of the two tables you want to save your Booking object to?


They do this via a form, adding the Bookings as objects in NSMutableArrays called bookingList and genevaBookingList, These lists are populated in Session's constructor as follows:

ec = defaultEditingContext();
bookingList = new NSMutableArray(EOUtilities.objectsForEntityNamed(ec,"Booking"));
genevaBookingList = new NSMutableArray(EOUtilities.objectsForEntityNamed(ec,"GenevaBooking"));

You now have two arrays populated with Booking objects, the fact that they came from different tables is gone.


On the admin page I add new bookings like this:

if(! editingObject) { // this line works
if(clubNumber == 1){ // first club selected
System.out.println("newBooking is: " + newBooking + " before bookingList is updated it is: " + s.bookingList); // this works
s.bookingList.addObject(newBooking);
System.out.println("after bookingList is updated it is: " + s.bookingList); // this works
s.sortObjects(s.bookingList);
} else { // second club selected
System.out.println("If I was adding a booking to the first table, I shouldn't have gotten here.");
s.genevaBookingList.addObject(newBooking);
s.sortObjects(s.genevaBookingList);
}

ec.insertObject(newBooking);
}


// Need to save new info here
ec.saveChanges(); // this seems to always add the new bookings into the GENEVA_BOOKING table


The problem is that the code seems to always add new Booking objects into the GENEVA_BOOKING table, regardless of the club number, or whether the object is added to bookingList or genevaBookingList. The run log shows it is adding it to GENEVA_BOOKING, and this is what happens. I have tried as many things as I can think of. Is there someplace outside of what I've discussed here where I should look?

1. the EOModel reflects a different table as stated above.
2. the code seems to get the data from the right tables.

Yes because you explicitly fetch from the right tables

3. the code inserts the data into only one of the tables, GENEVA_BOOKING.

That's just the luck of the draw, I don't know how EOF makes the decision with a conflict like this (two Classes mapped to the same Entities) but (obviously) it cannot decide correctly with the info it has.


I am using WO 5.2, XCode 1.5 on OS X 10.3.6

If anyone has any ideas where else I should look, or whatever info I need to consider, I'd appreciate it.

I don't know what your model looks like, but maybe that's where you should be looking. Instead of creating new entities and tables, can you not have Booking objects that are related to Club or Location objects? For instance, if you need to support multiple clubs (locations) maybe you should have a model that looks like this:


	Club  -->> Booking

Adding clubs and keeping their bookings separate then becomes easy.

;david

--
David LeBer
Codebase Software Systems
site:   http://www.codebase.ca
blog: http://david.codebase.ca

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
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

  • Follow-Ups:
    • Re: Strange EO issue
      • From: MacFirst <email@hidden>
References: 
 >Strange EO issue (From: Andrew Kinnie <email@hidden>)

  • Prev by Date: Strange EO issue
  • Next by Date: Re: Strange EO issue
  • Previous by thread: Strange EO issue
  • Next by thread: Re: Strange EO issue
  • Index(es):
    • Date
    • Thread