Re: Questions on Fetching with Conditions

Georg von Bülow <[email protected]>
Newsgroups gmane.comp.web.webobjects.devel
Message-ID <[email protected]>
Hi Satoru,

also to 1):
If you are using Project WONDER, you can use

ERXEOControlUtilities.objectCountWithQualifier(EditingContext ec, String
entityName, EOQualifier qualifier);

This will return only an int without creating any objects.

Regards,
Georg

> Hi,
>
> I have a couple of questions:
>
> 1) Is there another way to fetch row count without using the raw row
> SQL or the obj.objects().count() method?
>
> e.g.
>
> String SQL = "select count(class_id) as count from clazz where use_id
> = 1";
> NSArray objects = EOUtilities.rawRowsForSQL(ec, "Clazz", SQL, null);
> NSDictionary dict = (NSDictionary)objects.objectAtIndex(0);
> String count = dict.objectForKey("COUNT");
>
> or
>
> int count = student.classes().count();
>
> The first one, I have to hard code the SQL.  The second one fetches
> all of the classes to count.  I do not wish to do that.
>
> 2) Is there another way to fetch "one" (limit 1) to-many relationship
> entity object sorted by a certain column in ascending/decending order
> without using the raw row SQL or having to fetch all of the objects
> using the obj.objects() and then sort?
>
> e.g.
>
> String SQL = "select * from clazz where user_id = '1' order by
> registration_date ASC limit 1";
> ....
> ....
> ..
>
> or
>
> NSArray classes = student.classes();
> ...
> .. (and then sort or get the last index of objects or whatever...)
> ..
>
> Thanks!
>
> Satoru
> _______________________________________________
> WebObjects-dev mailing list
> [email protected]
> http://www.omnigroup.com/mailman/listinfo/webobjects-dev
>
>


-- 
Georg von Bülow
[email protected]

Niterói - Brasil
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.