• 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: Lachlan Deck <email@hidden>
  • Date: Wed, 9 Sep 2009 09:07:48 +1000

On 08/09/2009, at 5:11 PM, Timo Hoepfner wrote:

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)

That shouldn't be the case as that (== defining an external name for the parent entity==) is vertical inheritance. And that sounds like the bug which I addressed for 5.4 in ERXEntity#hasExternalName (the bug being introduced in 5.4) because it was mucking up my vertical inheritance stuff by creating auto_pk entries for the subclass instead of the parent so that the pks were not unique across the VI tree.


(Abstract btw, for clarify, has nothing to do with whether or not the entity maps to a table but whether or not it can be instantiated).

- 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.

Perhaps that's because EOF is confused by the mis-modelling.

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?

with regards, --

Lachlan Deck



_______________________________________________
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: Mike Schrag <email@hidden>
References: 
 >EOF inheritance (From: Jon Nolan <email@hidden>)
 >Re: EOF inheritance (From: Timo Hoepfner <email@hidden>)

  • Prev by Date: Re: Project Wonder Libs missing
  • Next by Date: UnsupportedClassVersionError caused by 10.6 developed WOA being deployed on 10.5 server?
  • Previous by thread: Re: EOF inheritance
  • Next by thread: Re: EOF inheritance
  • Index(es):
    • Date
    • Thread