Issue Details (XML | Word | Printable)

Key: OPENJPA-80
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Jakob Braeuchi
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
OpenJPA

Bad Escaping for LIKE in MySQL

Created: 13/Nov/06 08:01 PM   Updated: 06/Mar/07 09:34 AM
Return to search
Component/s: query
Affects Version/s: None
Fix Version/s: 0.9.7

Time Tracking:
Not Specified

Environment:
openJPA 0.9.7
MySQL 5.0.15

Resolution Date: 06/Mar/07 09:34 AM


 Description  « Hide
the following query :

em.createQuery("select k from KategorieGruppe k where k.bezeichnung like ?1 order by k.bezeichnung asc");

generates an sql-statement with a bad escaping character '\' for MySQL :

SELECT t0.id, t0.bezeichnung FROM ekv2kategoriegruppe t0 WHERE (t0.bezeichnung LIKE ? ESCAPE '\') ORDER BY t0.bezeichnung ASC

the correct escaping would be '\\'.

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Jakob Braeuchi added a comment - 13/Nov/06 08:16 PM
the variable searchStringEscape must be correctly set in org.apache.openjpa.jdbc.sql.MySQLDictionary:

...
 searchStringEscape = "\\\\";
...

Marc Prud'hommeaux added a comment - 13/Nov/06 08:22 PM
Note that you should be able to work around the issue for the time being by setting the property "openjpa.jdbc.DBDictionary" to "searchStringEscape=\\" in your persistence.xml file or in the properties you use to create the EntityManagerFactory.