Hi Joe,
If you have a smaller dataset, you can avoid all the nasty JDBC stuff and
achieve the goal using:
public NSArray<YourEntity> entities() {
NSArray<YourEntity> entities =
EOUtilities.objectsForEntityNamed(session().defaultEditingContext(),
YourEntity.ENTITY_NAME);
return YourEntity.DATE_COLUMN.dot("month").eq(2).filtered(entities); //
I've used 2 (February) to filter the records. DATE_COLUMN is ERXKey
}
Even if you have comparatively large dataset then you can do something as
follows to do some memory optimization:
public NSArray<YourEntity> entities() {
NSArray<YourEntity> entities = new NSMutableArray<YourEntity>();
NSArray<NSDictionary> rows =
EOUtilities.rawRowsWithQualifierFormat(session().defaultEditingContext(),
YourEntity.ENTITY_NAME, null, null);
for(NSDictionary row :
YourEntity.DATE_COLUMN.dot("month").eq(2).filtered(rows)) { // I've used 2
(February) to filter the records. DATE_COLUMN is ERXKey
entities.add((YourEntity)
EOUtilities.objectFromRawRow(session().defaultEditingContext(),
YourEntity.ENTITY_NAME, row));
}
return entities;
}
Farrukh
On 2010-06-02, at 2:18 AM, Joe Kramer wrote:
> Hi Chuck,
>
> Thanks for the response. Generally I avoid "non trivial" things as much as
> possible because I'm lazy...oops... I mean keenly focused on efficiency (that
> sounds better). But I think in this case the SQL approach may be worth it.
> In looking at the EOSQLQualifier docs I see that it is deprecated. It looks
> like using EOFetchSpecification.setHints() should do the trick in this case.
> Thanks for weighing in!
>
> Regards,
>
> Joe
>
> On Tue, Jun 1, 2010 at 3:53 PM, Chuck Hill <[email protected]> wrote:
>
> On Jun 1, 2010, at 3:30 PM, Joe Kramer wrote:
>
> Hi all,
>
> I may be barking up the wrong tree here, but I wanted someone to confirm that
> for me. I have a simple Person EO with a NSTimestamp attribute for
> birthdate. I'm wondering if it is possible to create a qualifier to get all
> the people whose birthday is in a particular month (May, for example). The
> year doesn't matter so I can't do a simple ">" or "<". If this isn't
> possible (or efficient) I can change the data model to capture the birth
> month separately. Then I can just set the month programatically when a new
> person is created and use that value as the qualifier. Just curious what
> others think.
>
>
> Define "possible". :-P The SQL way is
>
> select extract(MONTH from col_name) from table_name;
>
> So you could write a custom qualifier to do this. Generally, writing
> qualifiers ranks as "non trivial". I don't know of an existing qualifier
> that you can use. Depending on your needs, SQL might be the way to go. See
> EOSQLQualifier JavaDocs.
>
>
> Chuck
>
> --
> Chuck Hill Senior Consultant / VP Development
>
> 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 protected])
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/webobjects-dev/farrukh.ijaz%40fuegodigitalmedia.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]