Re: Entity Inheritance
Re: Entity Inheritance
- Subject: Re: Entity Inheritance
- From: Ken Anderson <email@hidden>
- Date: Sun, 30 Nov 2008 21:50:31 -0500
The answer, as usual is, it depends.
Yes, you CAN get away with it - but EOF will generate inconsistent
results, and it points to a possible issue in the modeling of your
problem domain.
When I've had similar situations come up, after some reflection, I
usually determine that I can handle this with static 'helper' classes
instead. What I'll do is have a field in the database that can only
be a certain set of values. Based on those values, I'll call methods
in specific classes to do the work that I would normally have placed
in the subclasses.
Regarding EOF, what happens is you end up with things in an
inconsistent state in your editing and database contexts. When you
update a SubBatch1 class to have typeId=3, it's still an instance of
SubBatch1. If you immediately destroy that object and refetch it as
SubBatch2, things will be OK, but it requires an extra amount of work
that's really not worth it. If you DON'T get rid of it immediately
and another object has a fault to the Batch super-entity, the existing
SubBatch1 object will be returned from the cache... with typeId set
to 3. Something I would think you would want to avoid....
My personal advice... Don't do it.
This question has been asked on the list before... you might want to
check the archives for other peoples' thoughts and advice.
Ken
On Nov 30, 2008, at 8:29 PM, Ted Archibald wrote:
I have a question about eo inheritance.
Let's say I have the following three entities:
Entity Batch - Table Batch - Class Batch extends ERXGenericRecord -
qualifier typeId = 1
Entity SubBatch1 - Table Batch - Class SubBatch1 extends Batch -
qualifier typeId = 2
Entity SubBatch2 - Table Batch - Class SubBatch2 extends Batch -
qualifier typeId = 3
Now, if I change the typeId of an eo will this cause problems and
or make WebObjects angry? From the experiments I've done it doesn't
seem to cause any problems, but down the road will this have
negative consequences?
_______________________________________________
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