Re: EOF inheritance
Re: EOF inheritance
- Subject: Re: EOF inheritance
- From: Timo Hoepfner <email@hidden>
- Date: Tue, 8 Sep 2009 09:11:32 +0200
Hi,
single table inheritance always worked fine for me. Random things to
watch out for:
- Be careful with NOT NULL constraints. Only make the columns in the
DB NOT NULL, when it must be NOT NULL in the *whole* inheritance
hierarchy (In Chuck and Sacha's most excellent book, there is a
section on that. Something like "the impossible constraint"). WOLips
takes care of that in most cases nowadays.
- Every non-abstract entity in the hierarchy needs a unique
restricting qualifier
- Don't forget to set the attribute that is used by the restricting
qualifier or switch on Wonder's auto-apply-restricting-qualifier feature
- Don't try to change the type of an EO once it exists. It will
confuse EOF.
horizontal inheritance also works fine in most cases, but fails in
some situations. Random notes:
- Depending on the DB you use, you have to have tables for abstract
entities (e.g. in Frontbase you need a table for the root entity, as
PK generation relies on it)
- Other than in single table inheritance, NOT NULL constraints are not
a problem, but you have to watch out for foreign key constraints, when
a relationship references an entity that has sub-classes
- For some queries, the wrong SQL is generated, e.g. (still have the
repro code flying around...)
public abstract class ServiceUnit extends ERXGenericRecord
public class ServiceProvider extends ServiceUnit
public class ServiceConsumer extends ServiceUnit
public class User extends ERXGenericRecord
User <<-> ServiceUnit
When you do a fetch for a User with a qualifier like
User
.LOGIN
.is("foo").and(User.SERVICE_UNIT.dot(ServiceUnit.NAME).is("provider"))
the SQL generated by EOF will only use the table for the abstract
entity ServiceUnit in the where clause and ignore the tables of the
concrete entites:
<com.webobjects.jdbcadaptor._FrontBasePlugIn$FrontbaseExpression:
"SELECT t0."id", t0."login", t0."serviceUnitID" FROM "User" t0 INNER
JOIN "ServiceUnit" T1 ON t0."serviceUnitID" = T1."id" WHERE
(t0."login" = 'foo' AND T1."name" = 'provider')">
In this case you will need to first fetch the ServiceUnit and then
pass it in the qualifier.
Timo
Am 07.09.2009 um 01:18 schrieb Jon Nolan:
I haven't used inheritance in years. My experience was that the
hassles you faced far outweighed the benefits of elegance of design.
I now have a project which begs for it. What say you? Do you use
inheritance or is my gut feeling correct in telling me to keep on
staying away?
Thanks,
Jon
_______________________________________________
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