Re: Subclass conflict with single-table mapping?
Re: Subclass conflict with single-table mapping?
- Subject: Re: Subclass conflict with single-table mapping?
- From: email@hidden
- Date: Tue, 13 Dec 2005 08:32:13 +0100
Drew,
I understand there are 3 classes: Employee,
Client and Consultant.
Of which class are employees with type
== 3?
I am afraid of you telling me that the
qualifier for Client is ((type == 1) or (type == 3)) while the one of Consultant
is ((type == 2) or (type == 3)). If this is the case, a row of type 3 is
mapped to either an instance of Client or an instance of Consultant the
first time it is read. From the on it will stay of that type. Thus even
if you excplicitly fetch for Client instances you may find a Consultant
instance in the resulting array.
What comes biting at you is object uniquing:
for a given global id (defined as top level entity + primary key) there
will be at most one enterprise object instance in a given editing context.
Thus the row {lastName = "Smith"; type
= 3; firstName = "John"; employeID = 1;} will
map an EO with global id (Employee, 1). This EO will be an instance of
either Client or Consultant.
In short: if some employees may be either
clients or consultants then inheritence is not the way to model things.
Pierre
Drew Thoeni <email@hidden> wrote on 12/13/2005
01:59:54 AM:
> 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.
>
> Dave Avendasora suggested this may be problematic. Perhaps the
> problems are playing out here.
>
> 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.
>
>
> 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
> **********************************************************************
**********************************************************************
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:
This email sent to email@hidden