db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Toru Suzuki <suzuki...@blue.ocn.ne.jp>
Subject Re: Why? Criteria.LIKE
Date Tue, 09 Dec 2003 04:04:03 GMT
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


Mime
View raw message