Re: Setting up horizontal inheritance
Re: Setting up horizontal inheritance
- Subject: Re: Setting up horizontal inheritance
- From: Chuck Hill <email@hidden>
- Date: Sat, 1 Nov 2008 17:25:57 -0700
On Oct 31, 2008, at 10:55 PM, Paul Hoadley wrote:
On 01/11/2008, at 3:17 PM, Chuck Hill wrote:
On Oct 31, 2008, at 9:39 PM, Paul Hoadley wrote:
After finding "Subclass Entity" in Entity Modeler, and re-making
the child entity specifying horizontal inheritance, this question
remains:
On 01/11/2008, at 11:19 AM, Paul Hoadley wrote:
2. Practical WebObjects (p. 32) states that horizontal
inheritance "puts a complete copy of each entity into a separate
table". Does EOF do this for me? That is, if I use
_AMPerson.createAMPerson(), does EOF put a row in the 'amperson'
table, and a corresponding row in the 'person' table?
I've just used _AMPerson.createAMPerson() to create a new
AMPerson. There's a new row in 'amperson', and nothing in
'person'. Have I misunderstood "complete copy" here? That is,
should there be a corresponding new row in 'person', or not?
No, Person will remain empty as it is abstract. Each concrete
entity is written to its own table. One row (and hence one table)
is written per EO.
OK. Tell me if this complicates things: Person is "abstract" in
this particular app, in that all I will be creating is AMPersons.
But Person is in a separate EO model, in a stand-alone framework. I
haven't marked Person abstract in Entity Modeler, as for some
applications it might be enough and I would actually instantiate it.
Are you sure you want Horizontal Inheritance?
Not completely.
Single table is usually the best choice.
I chose HI because I wanted to avoid what Lachlan describes in
another mail:
For both VI and STI you usually define a column in the parent
(e.g., called entityType) that's populated on awakeFromInsertion
with e.g., if (entityType() == null) setEntityType(entityName());
In the model you then in each child entity set the definition for
the restricting qualifier to e.g., (entityType like 'EntityName').
Avoiding that seems like a poor goal. You should choose the
inheritance scheme that is the most fetch efficient unless you are
working with a legacy data model. Or you are a database weenie who
cares more about pretty tables than performance. :-P Just keep
repeating to yourself "the database is an artifact of the
implementation".
Maybe I should take a step back. I assumed I wanted inheritance at
all because I have a basic EO called Person in a model in a utility
framework, and in a particular app I want to add three
relationships to app-specific EOs. (In other apps, Person might be
sufficient as it is, and I would instantiate it as an EO.) Is this
an example of where one would use inheritance? Is HI a bad choice,
and should I use STI instead?
I'd probably use HI in this case. I might also just dynamically add
the relationships when the models are loaded. HI is less tricky.
Chuck
--
Chuck Hill Senior Consultant / VP Development
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve specific
problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
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