You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Dave Newton <da...@solaraccess.com> on 2003/11/14 19:40:39 UTC
Re: Why? Criteria.LIKE
On Mon, 2003-11-24 at 21:09, Toru Suzuki wrote:
> String note = "\*comment";
> Criteria cri = new Criteria();
> cri.add(PERSON.NOTE, (Object)(note + "%"), Criteria.LIKE);
>
> SQL log is
> SELECT PERSON.NAME, PERSON.NOTE FROM PERSON
> WHERE PERSON.NOTE LIKE '\comment%'
>
> I expected
> WHERE PERSON.NOTE LIKE '*comment%'
Did this get answered?
Is it just a java string issue (need to backslash a backslash)?
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org
Re: Why? Criteria.LIKE
Posted by Toru Suzuki <su...@blue.ocn.ne.jp>.
Dave,
Thanks for your reply.
sorry for my english.
I wrote by mistake
> String note = "\*comment";
String note = "\\*comment";
sorry.
but I don't get this answered.
SqlExpression.buildLike javadoc
> Takes a columnName and criteria and builds an SQL phrase based
> on whether wildcards are present and the state of the
> ignoreCase flag. Multicharacter wildcards % and * may be used
> as well as single character wildcards, _ and ?. These
> characters can be escaped with \.
but These characters can not be escaped with \.
>String equalsOrLike = " = ";
>int position = 0;
>StringBuffer sb = new StringBuffer();
>while (position < criteria.length())
>{
> char checkWildcard = criteria.charAt(position);
>
> switch (checkWildcard)
> {
> case BACKSLASH:
> // Determine whether to skip over next character.
> switch (criteria.charAt(position + 1))
> {
> case '%':
> case '_':
> case '*':
> case '?':
> case BACKSLASH:
> position++;
> break;
> }
> break;
> case '%':
> case '_':
> equalsOrLike = comparison.toString();
> break;
> case '*':
> equalsOrLike = comparison.toString();
> checkWildcard = '%';
> break;
> case '?':
> equalsOrLike = comparison.toString();
> checkWildcard = '_';
> break;
> }
>
> sb.append(checkWildcard);
> position++;
>}
position++ but checkWildcard not replaced.
Am I wrong?
> On Mon, 2003-11-24 at 21:09, Toru Suzuki wrote:
> > String note = "\*comment";
> > Criteria cri = new Criteria();
> > cri.add(PERSON.NOTE, (Object)(note + "%"), Criteria.LIKE);
> >
> > SQL log is
> > SELECT PERSON.NAME, PERSON.NOTE FROM PERSON
> > WHERE PERSON.NOTE LIKE '\comment%'
> >
> > I expected
> > WHERE PERSON.NOTE LIKE '*comment%'
>
> Did this get answered?
>
> Is it just a java string issue (need to backslash a backslash)?
>
> Dave
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org