Re: EOF issues
Re: EOF issues
- Subject: Re: EOF issues
- From: Ken Anderson <email@hidden>
- Date: Tue, 28 Apr 2009 22:41:18 -0400
Harvey,
There are many discussions about this in the history, but the basic
idea is this - EOF doesn't like changing attributes that determine the
class/entity of an object. The general consensus from the last time
this came up is, change how you do things so you don't have to do this.
How much behavior is actually different here? Do you really need sub-
entities for this? I remember a discussion at WWDC a number of years
ago where the iTunes team said that out of 400 entities, they only had
2 sets of object hierarchies.
One way I approach different behaviors when I don't want sub-entities
is to have a set of objects that do the special work you'd have a
subclass do, and have it determine which one to use dynamically. For
instance, if the type is Student (right now) and you ask how many
classes it is taking, the helper class could make that determination
and return the result. You can use key-value coding to make this
nearly transparent to the users of the Person object.
Ken
On Apr 28, 2009, at 10:31 PM, M.Y. Tjoe wrote:
Hi all,
I am currently investigating an interesting problem. Here is the
problem description:
A database table "Person" is represented in EOModel as "Person" with
3 childs "Staff" , "Student", "External". There is type column in
Person to tell if he is staff/student/external.
The problem is that when a "External" object is fetched into a ec,
changed its type to "student" and saved changes,
i.e.
External external = External.fetchExternal(ec, External.ID_KEY,
'12345');
external.setType("student");
external.editingContext().saveChanges();
then in the same ec (or different ec) the now "student" still being
recognized as External somehow.
When you do
Student student = Student.fetchRequiredStudent(ec, Student.ID_KEY,
'12345');
or even
Person student = Person.fetchRequiredPerson(ec, Person.ID_KEY,
'12345');
An databaseContextFailedToFetchObject exception is thrown.
I am thinking the objects graph is now broken because Staff Object
supposed to be vanished from the graph but it didn't.
Any idea??
Regards,
Harvey
_______________________________________________
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
_______________________________________________
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
References: | |
| >EOF issues (From: "M.Y. Tjoe" <email@hidden>) |