Re: caseInsensitiveLike unknown operator exception
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