• 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
Of Inheritance and AwakeFromInsertion
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Of Inheritance and AwakeFromInsertion


  • Subject: Of Inheritance and AwakeFromInsertion
  • From: David Avendasora <email@hidden>
  • Date: Wed, 19 Mar 2008 08:21:52 -0400

Hi all,

I've run into something that _seems_ to work, but just seems "wrong" and I don't see how to do it "right".

I have the following inheritance structure in my model:

LotCode (NOT abstract)
ManufacturedBatch extends LotCode.

When I call awakeFromInsertion on the superclass I do it as follows :

public void awakeFromInsertion(EOEditingContext ec) {
super.awakeFromInsertion(ec);
if (lotCodeType() == null) {
setLotCodeType(1);
}
}

But when I call awakeFromInsertion on the subclass I have to do this:

public void awakeFromInsertion(EOEditingContext ec) {
super.awakeFromInsertion(ec);
if (lotCodeType() == null || lotCodeType.equals(1)) {
setLotCodeType(1);
}
}

I know that you should _never_ change the class of an EO after creating it, but that's exactly what I'm doing here. When awakeFromInsertion is called on the subclass, the first thing it does is call super.awakeFromInsertion, which sets the class to LotCode, but then I change it to a ManufacturedBatch immediately after.

If I don't do this, a call of ManufacturedBatch newManufacturedBatch = new ManufacturedBatch() returns a LotCode instead.

So, is this an exception to the rule "never change an EO's class" or is it because I'm doing it in the awakeFromInsertion process that it is okay?

Or is it wrong to do this and I just haven't been bitten by it yet?

Dave
 _______________________________________________
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: Of Inheritance and AwakeFromInsertion
      • From: Chuck Hill <email@hidden>
    • Re: Of Inheritance and AwakeFromInsertion
      • From: David Avendasora <email@hidden>
    • Re: Of Inheritance and AwakeFromInsertion
      • From: David LeBer <email@hidden>
  • Prev by Date: Re: DST fixed for 08 in 5.4??
  • Next by Date: Re: Of Inheritance and AwakeFromInsertion
  • Previous by thread: Re: AjaxObserveField
  • Next by thread: Re: Of Inheritance and AwakeFromInsertion
  • Index(es):
    • Date
    • Thread