Re: Of Inheritance and AwakeFromInsertion
Re: Of Inheritance and AwakeFromInsertion
- Subject: Re: Of Inheritance and AwakeFromInsertion
- From: Chuck Hill <email@hidden>
- Date: Wed, 19 Mar 2008 07:59:24 -0700
On Mar 19, 2008, at 5:41 AM, David Avendasora wrote:
On Mar 19, 2008, at 8:33 AM, David LeBer wrote:
On 19-Mar-08, at 8:21 AM, David Avendasora wrote:
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've never used a concrete superclass but how about:
Superclass:
public void awakeFromInsertion(EOEditingContext ec) {
super.awakeFromInsertion(ec);
if (lotCodeType() == null) setLotCodeType(1);
}
Subclass:
public void awakeFromInsertion(EOEditingContext ec) {
if (lotCodeType() == null) setLotCodeType(2);
super.awakeFromInsertion(ec);
}
I thought about this, but since it is also an "EO-No-No" to do
_anything_ before calling awakeFromInsertion I didn't want to do
anything before inserting the super.
I think the "EO-No-No" is to do _anything_ before calling
insertObject(). I think that code should be OK. Just be aware than
EOF won't have created any mandatory, owned objects in relationships
before the call to super.
Chuck
--
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