Re: From OpenBase To MSSQLServer2000 (EOModeller)
Re: From OpenBase To MSSQLServer2000 (EOModeller)
- Subject: Re: From OpenBase To MSSQLServer2000 (EOModeller)
- From: Jonathan Rochkind <email@hidden>
- Date: Wed, 04 Jun 2003 14:36:13 -0500
At 01:35 PM 6/4/2003 -0500, Ricardo Strausz wrote:
What you actually need is something like:
SELECT COUNT(*) FROM TB_JOB_PICTURE WHERE TB_JOB_PICTURE.TB_JOB_ID =
<TB_JOB_ID value for the current TB_JOB row>
I don't recall ever using such a derived attribute, so I'm not sure what
EOF-specific (i.e., non-SQL) syntax might be substituted for the value of
the current row's primary key. Now I wonder whether such a derived
attribute is supported by EOF.
The way I've approached this is to define a derived attribute (on the
TB_JOB_PICTURE) "count(*)" that is _not_ a class property. This means it
won't be automatically included in any of your EO objects at all, but that
you can do a seperate fetch when you need the count. This may or may not
be acceptable, but it works for me. If it were included as a class
property, it would slow down fetches, as someone else mentions, obviously
becuase every fetch to that class will create SQL that has the db compute
this value for every row. Not included---well, the main reason I do it is
just because it works, and it's simple. And for the uses I need to put it
to, having to do a seperate fetch to get the count works fine.
To set up the seperate fetch for the count, you use a fetch specification
set with rawRowAttributes including just your derived count attribute. You
will get a dictionary (or dictionaries) back as a result which include just
one key/value pair each, with the value being your count. The qualifier
for the fetch can be an ordinary qualifier to select the
TB_JOB_PICTURE-corresponding objects you want. You can follow
relationships, and include non-class-properties (like a pk!) in the
qualifier. Also, keep in mind that you can have a qualifier along the
lines of:
Department d;
EOQualifier qual = EOQualifier.qualifierWithQualifierFormat("department =@
", new NSArray(d));
Assuming you are qualifying Employees who have a to-one relationship
'department' to Department. It just works, the SQL joining on the pk and fk
involved are generated for you. Very handy!
Hope this helps,
--Jonathan
As far as I remember, EOF DO support such derived atributes; they have to
be flatened in EOModeler. But as far as I remember they slow down the fetch.
I suppose you could define a stored procedure instead if you
didn't want to fetch the related objects in order to count them on the >
client.
Aloha,
Art
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.