Hi, Thanks that Solution works great. I will try to find out if that will work in the Customers DB for more Testing.
But I am really confused why nobody else has a need for that kind of Search. I think there is a need for an ERXQ.constainsWildCard ... Command. On 2010/11/10, at 22:37, Mark Wardle wrote: > I think I'd do this with raw SQL. > > I needed to execute raw SQL to optimise a particular query and fetch. > I also wishes to avoid a trip to the database for each individual > fetch - one to identify the PKs and then one to fetch each enterprise > object. Therefore, not finding anything in Wonder, I asked the mailing > list (http://osdir.com/ml/webobjects-dev/2010-02/msg00236.html) and > wrote this: > > /** > * Executes a raw SQL statement returning an array of EOGlobalIDs. > * The raw SQL should return sufficient columns to allow the raw row > to be converted into an > * enterprise object. > * You will usually need to convert column names to attribute names > to allow the raw rows > * to be converted properly. > * > * @param ec - editing context > * @param entityName - name of the entity that the raw rows will be > converted to > * @param sql - the raw SQL statement to be executed > * @param columns - array of attribute names to replace the column > names that will arrive from the database > * @return > */ > public static NSArray<EOGlobalID> executeRawSql(EOEditingContext ec, > String entityName, String sql, NSArray<String> columns) { > EOModelGroup modelGroup = ERXEOAccessUtilities.modelGroup(ec); > EOEntity entity = modelGroup.entityNamed(entityName); > String modelName = entity.model().name(); > NSArray<NSDictionary<?,?>> rawRows = > EOUtilities.rawRowsForSQL(ec, > modelName, sql, columns); > NSMutableArray<EOGlobalID> gids = new > NSMutableArray<EOGlobalID>(rawRows.count()); > for(NSDictionary<?,?> row : rawRows) { > EOGlobalID gid = entity.globalIDForRow(row); > if (gid==null) throw new NullPointerException("Could > not fetch > global ID for raw row: " + row); > gids.add(gid); > } > return gids; > } > > I then use ERXEOGlobalIDUtilities.fetchObjectsWithGlobalIDs to > convert all of this data into enterprise objects. > > I'm sure this could all be optimised further, but it works and one > only has a single SELECT command issued against the database. > > Best wishes, > > Mark > > On 10 November 2010 10:45, Cheong Hee (Gmail) <chn...@gmail.com> wrote: >> Hi Ken >> >> So sorry that I misunderstood your question. After spending some time, >> I think this is what you need. >> >> p = Pattern.compile("\\Q*\\E"); >> m = p.matcher(input); >> if (m.find()) { >> System.err.println("test starts" + >> " with * signs...input: " + input); >> } >> But then the downside is you will have to enumerate each string one at a >> time. >> >> Cheers >> >> Cheong Hee >> >> >> ----- Original Message ----- >> From: ISHIMOTO Ken >> To: Farrukh Ijaz >> Cc: WebObjects Development >> Sent: Wednesday, November 10, 2010 5:44 PM >> Subject: Re: wildcard Query >> Hi Farrukh, >> Sounds nice, I will take a look at that and give you feedback. >> >> On 2010/11/10, at 10:09, Farrukh Ijaz wrote: >> >> Hi Ken, >> I spent some time exploring all the possibilities at the EOF level but it >> looks like it does not work at the EOF level. I also inspected the >> PostgresPlugin and found that the escape character is "|" instead of "\\" >> but still it doesn't work. If your data is not very large, you can do >> something like this. >> create your own custom class for EOQualifierEvalution called >> RegExpEvaluation as follows: >> public static class RegExpEvaluation implements EOQualifierEvaluation { >> String key, pattern; >> public RegExpEvaluation(String key, String pattern) { >> this.key = key; >> this.pattern = pattern; >> } >> public boolean evaluateWithObject(Object obj) { >> if (obj instanceof NSKeyValueCoding) { >> Object value = ((NSKeyValueCoding) obj).valueForKey(key); >> return (value instanceof String) && ((String) value).matches(pattern); >> } >> return false; >> } >> } >> Fetch all the rows for the entity and using ERXArrayUtilities method as >> follows: >> EOFetchSpecification fs = new EOFetchSpecification(M_User.ENTITY_NAME, null, >> null); >> NSArray<ArticleDetail> eoz = >> session().defaultEditingContext().objectsWithFetchSpecification(fs); >> eoz = ERXArrayUtilities.filteredArrayWithQualifierEvaluation(eoz, new >> RegExpEvaluation(M_User.NAME, ".*\\*.*")); >> Hope this may help. >> Farrukh >> On 2010-11-09, at 8:33 PM, ISHIMOTO Ken wrote: >> >> No >> On 2010/11/09, at 15:48, Farrukh Ijaz wrote: >> >> Try using "*[*]*" and see it works? >> Farrukh >> >> Sent from my iPhone >> On 2010-11-09, at 5:34 PM, ISHIMOTO Ken <k...@ksroom.com> wrote: >> >> Hi everyone, >> I am fighting with a Qualifier and my Question is "Is there any way for >> query all Data with an in." >> DataSample : >> Mike >> Chuck >> Dav*id >> Ken >> Like code bellow but the "*" is a Wildcard and won't work. >> EOQualifier qualifier = M_User.NAME.contains("*"); >> I would love to find any Record with "*". >> >> Is there any trick or command to get all Objects with an "*" ? >> >> Thank you >> -------------------------------------------------------- >> K's ROOM (ISHIMOTO Ken) >> -------------------------------------------------------- >> [E-Mail] <k...@ksroom.com> >> [iChat:] <ibase_...@mac.com> >> [HP] http://www.ksroom.com/ >> _____________________________________________________________________ >> This e-mail has not been scanned for viruses because it was written on an >> Mac, >> and there are NO Viruses on an Apple Computer. >> For further information visit http://www.apple.com >> >> _______________________________________________ >> Do not post admin requests to the list. They will be ignored. >> Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) >> Help/Unsubscribe/Update your Subscription: >> http://lists.apple.com/mailman/options/webobjects-dev/farrukh.ijaz%40fuegodigitalmedia.com >> >> This email sent to farrukh.i...@fuegodigitalmedia.com >> >> >> ________________________________ >> >> _______________________________________________ >> Do not post admin requests to the list. They will be ignored. >> Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) >> Help/Unsubscribe/Update your Subscription: >> http://lists.apple.com/mailman/options/webobjects-dev/chng34%40gmail.com >> >> This email sent to chn...@gmail.com >> >> _______________________________________________ >> Do not post admin requests to the list. They will be ignored. >> Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) >> Help/Unsubscribe/Update your Subscription: >> http://lists.apple.com/mailman/options/webobjects-dev/mark%40wardle.org >> >> This email sent to m...@wardle.org >> > > > > -- > Dr. Mark Wardle > Specialist registrar, Neurology > Cardiff, UK _______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com