Re: select 'top' query??
Re: select 'top' query??
- Subject: Re: select 'top' query??
- From: Serge Froment <email@hidden>
- Date: Thu, 25 Mar 2004 10:24:08 -0500
In my photo site, I need to do several fetches for which EOF cannot
generate proper and efficient SQL, including the use of TOP. Here is
how I do that:
StringBuffer sql = new StringBuffer("SELECT TOP(");
if (index != 0)
{
sql.append(index);
sql.append(",");
}
sql.append(count);
sql.append(") ");
sql.append(entityColumns("Photo", "P"));
EOFetchSpecification fetchSpecification = new
EOFetchSpecification("Photo", null, null);
fetchSpecification.setHints(new NSDictionary(sql.toString(),
EODatabaseContext.CustomQueryExpressionHintKey));
return editingContext.objectsWithFetchSpecification(fetchSpecification);
The entityColumn() method inserts the column names for all entity's
attributes and the FROM clause using the EOModel. This way, EOF still
creates normal EOGenericRecord-like objects from my custom SQL.
Serge Froment
http://www.serge-froment.com
_______________________________________________
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.