• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: select 'top' query??
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


References: 
 >select 'top' query?? (From: Jonathan Rochkind <email@hidden>)
 >Re: select 'top' query?? (From: "WebObjects EMail" <email@hidden>)

  • Prev by Date: Download File MimeType
  • Next by Date: Re: Off Topic : XCode, Java and Code Completion
  • Previous by thread: Re: select 'top' query??
  • Next by thread: Re: select 'top' query??
  • Index(es):
    • Date
    • Thread