[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2077) Providing an escape sequence for Criteria queries

Tobias Dietl (JIRA) noreply at atlassian.com
Thu Sep 14 11:15:54 EDT 2006


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2077?page=comments#action_24440 ] 

Tobias Dietl commented on HHH-2077:
-----------------------------------

sorry, I got the sql queries wrong...

If you want to search for '_abc' in MySQL, you have to use:
    value like '\_abc' 
or 
    value like '\_abc' escape '\\';

In Oracle or HSQLDB, you have to use:
    value like '\_abc' escape '\'
and not 
    value like '\_abc'

As you can see, simple escaping with '\' does not work with Oracle and HSQLDB, so I wanted to use another escape sequence '|'. Unlike with HQL queries, unfortunately, there is no way of setting the escape sequence for Criteria queries.


> Providing an escape sequence for Criteria queries
> -------------------------------------------------
>
>          Key: HHH-2077
>          URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2077
>      Project: Hibernate3
>         Type: Improvement

>   Components: query-criteria
>     Versions: 3.1.3, 3.2.0 cr1, 3.2.0.cr2, 3.2.0.cr3, 3.2.0.cr4
>  Environment: Hibernate 3.1.3, MySQL, HSQLDB, Oracle
>     Reporter: Tobias Dietl

>
> Original Estimate: 3 hours
>         Remaining: 3 hours
>
> Up to now, there is no way of setting the escape sequence to use for string comparisions with like for Criteria queries. 
> This is necessary as MySQL on the one hand and HSQLDB / Oracle on the other behave differently...
> If you want to search for '_abc' in MySQL, you have to use:
>     value like '\\_abc'
> In Oracle or HsqlDB, you have to use:
>    value like '\_abc'
> If you want to switch to another escape sequence like '|' , you can set it in HQL with value like '|_abc' escape '|'. Unfortunately, there is no way of setting it for Criteria queries, which would force me to rewrite all my Criteria queries in HQL. It would really be nice if the feature/improvement would be added...

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira




More information about the hibernate-issues mailing list