• 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: caseInsensitiveLike unknown operator exception
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: caseInsensitiveLike unknown operator exception


  • Subject: Re: caseInsensitiveLike unknown operator exception
  • From: Lachlan Deck <email@hidden>
  • Date: Sat, 27 Sep 2008 22:21:51 +1000

On 27/09/2008, at 7:21 AM, Nathan Hadfield wrote:

A client ran into this exception when performing a fetch with this qualifier: "((deleted=0) or (deleted=nil)) and (accountId=1) and (username caseInsensitiveLike %@)":

Unknown operator:<class com.webobjects.foundation.NSSelector (methodName=caseInsensitiveLike)>

Try using EOKeyValueQualifier (which gives you compile safety) rather than qualifierWithQualifierFormat.
Also try not exposing foreign keys unless you really need to.


public User getUserForLoginId( String loginId, int loginType, Preference aPreference ) {

NSMutableArray andQuals = new NSMutableArray();
andQuals .addObject( EOQualifier.qualifierWithQualifierFormat( "(deleted = 0) or (deleted = nil)", null ) );
if( aPreference != null )
andQuals .addObject( EOQualifier.qualifierWithQualifierFormat( "accountId = " + aPreference.account().id(), null ) );
if( loginType == USERNAME_LOGIN )
andQuals .addObject( EOQualifier.qualifierWithQualifierFormat( "username caseInsensitiveLike %@", new NSArray( loginId ) ) );

andQuals.addObject( new EOOrQualifier( new NSArray( new Object[] {
new EOKeyValueQualifier( User.DELETED_KEY, EOQualifier.QualifierOperatorEqual, 0 ),
new EOKeyValueQualifier( User.DELETED_KEY, EOQualifier.QualifierOperatorEqual, NullValue )
} ) );
if ( aPreference != null )
andQuals.addObject( new EOKeyValueQualifier( User.ACCOUNT_KEY, EOQualifier.QualifierOperatorEquals, aPreference.account() ) );
if ( loginType == USERNAME_LOGIN )
andQuals.addObject( new EOKeyValueQualifier( User.USERNAME_KEY, EOQualifier.QualifierOperatorCaseInsensitiveLike, loginId ) );

EOQualifier qual = new EOAndQualifier( andQuals );

EOFetchSpecification fetchSpec = new EOFetchSpecification( "User", qual, null );
fetchSpec.setRefreshesRefetchedObjects( true );


NSArray matchingUsers = ec.objectsWithFetchSpecification( fetchSpec );

with regards, --

Lachlan Deck



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >caseInsensitiveLike unknown operator exception (From: Nathan Hadfield <email@hidden>)

  • Prev by Date: Re: Measuring the worker thread count
  • Next by Date: Re: ERXApplicaton or WOApplication
  • Previous by thread: caseInsensitiveLike unknown operator exception
  • Next by thread: Fwd: WebObjects Error in Wonder D2W when populating MS SQL Server example
  • Index(es):
    • Date
    • Thread