Re: Subclass conflict with single-table mapping?
Re: Subclass conflict with single-table mapping?
- Subject: Re: Subclass conflict with single-table mapping?
- From: Chuck Hill <email@hidden>
- Date: Mon, 12 Dec 2005 17:19:16 -0800
On Dec 12, 2005, at 4:59 PM, Drew Thoeni wrote:
See below...
On Dec 12, 2005, at 7:12 AM, email@hidden wrote:
What is the primary key of your Employee table?
employeID (long integer)
Does the database's primary key definition match with what you
declared in EOModeler?
Yep. Using Frontbase LONGINT
Can you be sure no Client shares a primary key with an Consultant?
Just have test data (only a few rows), so I've been able to verify
that there are no duplicate keys. However, some clients are also
consultants so they share a type. Client alone is type==1,
consultant alone is type ==2, an employee who can be a client or
consultant is type==3.
Um, that is NOT inheritance. There is no "some" in inheritance.
Either _all_ clients are also consultants or _no_ clients are also
consultants. Java won't do this, neither will EOF. I can't think of
any language that does, but there are probably some, somewhere.
You could make a third subclass, ClientConsultant, but I think you
are just heading into the Land of Hurt doing that.
You need to get rid of inheritance. Take a look at the Role pattern
(first Google hit http://www.geocities.com/tablizer/prpats.htm#role).
Or just infer it by the relationships.
Dave Avendasora suggested this may be problematic. Perhaps the
problems are playing out here.
Problematic. Yeah. It will defiantly be problematic. Problematic
is probably as good as this gets. :-)
Did you configure the qualifier (e.g. type == 3) for all of your
sublclasses?
Yep. But in EOModler, I believe you use a single "=", at least I
did. I'm thinking this is not the problem though as I can use
client.lastName as a displayString but not consultant.lastName.
Separately, Wolfram suggested I likely have bound variables set
incorrectly. I have checked that again and it seems not to be the
problem. It seems your point of having a client who is also a
consultant may be the issue.
Oh yeah! :-)
Chuck
Pierre
webobjects-dev-bounces+pierre.bernard=email@hidden wrote
on 12/12/2005 02:48:38 AM:
> Background
> I have an Employee object that has two (actually more, but these
two
> will suffice to explain the problem) subclassed objects: Client and
> Consultant. I also have a Project object that a Client requests and
> a Consultant works on.
>
> The Employee, Client, and Consultant objects are concrete (as users
> want to add to the employee object but select from the subclassed
> objects). There is a one-to-many join between Client and Project
and
> Consultant and Project (a Project has only one Client and only one
> Consultant).
>
> Problem
> When I display a page that is intended to allow a new project to be
> added and has PopUp Buttons to allow a client and consultant to be
> selected, I get an exception as follows:
>
> java.lang.IllegalArgumentException: While trying to set the field
> "consultantItem" on an object of type ProjectDetailPage we expected
> a Consultant but received a Client with a value of {values =
> {lastName = "Smith"; type = 3; firstName = "John"; projects = ")>";
> }; this = ""; }. This often happens if you forget to use a
formatter.
>
> There is an NSArray of Consultants (consultantList) and a holder
> variable (consultantItem). Same for client.
>
> This excpetion is being caused by having the displayString on a
> PopUp Button in WOBuilder set to consultant.lastName. If I leave
> that attribute empty the page will load and function (but, of
> course, I get a long set of values in the PopUp display. I can set
> the client popup displayString to client.lastName and all works
> fine. It's only when I try to set the displayString for consultant
> (or any other of the employee subclasses) that I get the above
> exception. For some reason WO thinks the object it's being
handed is
> a Client, though it has been defined as a Consultant.
>
> This is my first implementation using subclasses. I've checked the
> model, and all variables, etc. But, I'm betting there's something
> I'm missing here.
>
> Any ideas would be appreciated.
>
> Regards,
>
> Drew _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
email@hidden
>
> This email sent to email@hidden
*********************************************************************
*
This email and any files transmitted with it are intended solely for
the use of the individual or entity to whom they are addressed.
If you have received this email in error please notify the sender
of this message. (email@hidden)
This email message has been checked for the presence of computer
viruses; however this protection does not ensure this message is
virus free.
Banque centrale du Luxembourg; Tel ++352-4774-1; http://www.bcl.lu
*********************************************************************
*
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40global-village.net
This email sent to email@hidden
--
Coming in 2006 - an introduction to web applications using WebObjects
and Xcode http://www.global-village.net/wointro
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