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.

Patrick Linskey made changes - 01/Mar/07 01:12 AM
Field Original Value New Value
Fix Version/s 0.9.7 [ 12312340 ]
Repository Revision Date User Message
ASF #515043 Tue Mar 06 09:33:06 UTC 2007 pcl OPENJPA-80: MySQL escape string for string matches queries
Files Changed
MODIFY /incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java

Patrick Linskey made changes - 06/Mar/07 09:34 AM
Resolution Fixed [ 1 ]
Status Open [ 1 ] Resolved [ 5 ]