db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jakob Braeuchi <jbraeu...@gmx.ch>
Subject Re: Proposal to support ESCAPE for Like-Criteria
Date Sat, 21 Feb 2004 19:24:39 GMT
hi larry,

i know that this breakes the paradigm to be database-independent. the situation 
we have now is also not really dbms-independent. the current implementation of 
wildcard-handling only accepts % and _ ; those wildcards are not supported by 
ms-access ! i think % and _ are the generally accepted wildcards and the 
character used for escaping wildcards is imo not defined. so that's why i 
proposed to leave it up to the user.

the following examples show three different ways of escaping wildcards:

  addLike("firstname", "h%|%", "escape '|'");
  addLike("firstname", "h%\\%", "escape '\\'");
  addLike("firstname", "h%=%", "escape '='");

i was also thinking of setting the escape-character globally:

LikeCriteria.setEscapeChar('\\');

this is actually the state of my current implementation (no need to specify the 
escape-clause)...but then i had a look at ms-access :(

jakob

Larry Streepy wrote:
> I would argue that specialized handling of the wildcard characters belongs
> in the DB-specific classes.  One of the goals (at least in my mind) is that
> OJB makes it fairly easy to move between database platforms without massive
> changes to your application.  The proposal below breaks that paradigm by
> requiring DB-specific handling for something as simple as wildcard handling.
> 
> I know I get no real vote, but take this as a plea to move this handling
> into the DB-specific layers.
> 
> Thanks.
> Larry.
> 
> 
> 
>>-----Original Message-----
>>From: Jakob Braeuchi [mailto:jbraeuchi@gmx.ch]
>>Sent: Saturday, February 21, 2004 6:44 AM
>>To: OJB Developers List; Nase.Paul@mayo.edu
>>Subject: Proposal to support ESCAPE for Like-Criteria
>>
>>hi all,
>>
>>i had a long discussion with paul r. nase about like criteria containing
>>escaped
>>wildcards (example: first name like 'h%\%' escape '\' looks for firstname
>>starting with 'h' and ending with '%'). for details see:
>>
>>  http://article.gmane.org/gmane.comp.jakarta.ojb.user/12505
>>
>>ojb currently does not properly support escaping of wildcards. while
>>experimenting with this feature i found that we have some dbms-dependent
>>problems:
>>
>>1.) escape character \ is the default in mysql so escape '\' is not
>>accepted.
>>we'd need '\\'
>>2.) replacing wildcards *, ? by %, _ does not work for ms-access.
>>3.) escaping wildcards is different in ms-access
>>
>>so i propose to use a manual escaping in like-criteria without replacing
>>wildcards. the user will have to provide the escape clause for the like-
>>criteria:
>>
>>addLike(attribute, criteria, escapeClause);
>>ie:
>>addLike("firstname", "h%\\%", "escape '\\'");
>>
>>ms_access: addLike("firstname", "h*[*]");
>>
>>the escape clause will be appended to the like-clause when building the
>>sql.
>>i'll implement a dedicated LikeCriteria to support escaping.
>>
>>what do you think about this ?
>>
>>jakob
>>
>>
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
>>For additional commands, e-mail: ojb-dev-help@db.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message