• 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: EOF inheritance
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: EOF inheritance
      • From: Lachlan Deck <email@hidden>
References: 
 >EOF inheritance (From: Jon Nolan <email@hidden>)

  • Prev by Date: Re: FOSS Reporting Libraries?
  • Next by Date: WOTable does not work for me with WO 5.4.2
  • Previous by thread: Re: EOF inheritance
  • Next by thread: Re: EOF inheritance
  • Index(es):
    • Date
    • Thread