For relationships you can put something like the method shown below in your custom EO subclass. One set of the eogen templates out there have this too IIRC. I added the check for ec changes since the count might be inaccurate otherwise and will definitely fail for new unsaved objects.....

    /**
* This method is protected since they are to be called by eogenerated templates. * If object not saved, uses standard array count, otherwise uses database count
     *
     * @param key
     * @return count for the given relationship.
     */
    protected Integer countForRelationship(String key)
    {
        if (editingContext().hasChanges()) {
            return (Integer) valueForKeyPath(key + "....@count");
        } else {
            EOQualifier qual = qualifierForRelationshipWithKey(key);

            String anEntityName = this.entityName();
EOEntity anEntity = EOModelGroup.defaultGroup().entityNamed(anEntityName); EORelationship aRelationship = anEntity.relationshipNamed(key); return ERXEOControlUtilities.objectCountWithQualifier(this.editingContext(), aRelationship
                    .destinationEntity().name(), qual);
        }
    }

HTH, Kieran

On Dec 11, 2008, at 5:17 AM, David Avendasora wrote:

Hi Jerry,

It appears that wocode is no longer there.

Can you possibly post the CountFetcher.java code here or some other easy to access place?

Thanks!

Dave

On Jan 21, 2006, at 3:40 PM, Jerry W. Walker wrote:

Hi, Miguel,

You might try CountFetcher.java which can be downloaded from:

  http://wocode.com/cgi-bin/WebObjects/WOCode.woa/2/wa/ShareCodeItem?itemId=429

Regards,
Jerry

On Jan 21, 2006, at 2:10 PM, Miguel Arroz wrote:

Hi!

This is probably very obvious, but... how can I count the objects that would be retuned by a fetch specification, but without actually fetching them (or creating faults for them)? What I would like to do is something like the COUNT SQL function.

Yours

Miguel Arroz

"We have no sympathy for the lost souls
We've chosen the path of disgrace
We give this life to our children
And teach them to hate this place" -- Apocalyptica, Life Burns!

Miguel Arroz
http://www.ipragma.com


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/jerrywwalker%40gmail.com

This email sent to [email protected]


--
__ Jerry W. Walker,
WebObjects Developer/Instructor for High Performance Industrial Strength Internet Enabled Systems

 [email protected]
 203 278-4085        office



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/webobjects%40avendasora.com

This email sent to [email protected]



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/kieran_lists%40mac.com

This email sent to [email protected]

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to