IBM Support

ORA-01424 for ORACLE database using OPEN JPA and / as an escape character

Troubleshooting


Problem

Named query does not work for the input character '\'. It throws: throws oracle error ORA-01424: missing or illegal character following the escape character

Symptom

Here is the NamedQuery :
.
@NamedQuery(name = "EmployeeLite.getEmployeesByLastName",
query = "SELECT e FROM EmployeeLite e WHERE
UPPER(e.lastName) LIKE :lastName")

Here is how we are setting the input parameter:
.
Query is:
em.createNamedQuery("EmployeeLite.getEmployeesByLastName");
query.setParameter("lastName",
lastName.toUpperCase(Locale.getDefault()));
.
Here is the generated query and the exception:

[3/2/09 14:27:06:778 EST] 00000023 ExceptionUtil E CNTR0020E: EJB
threw an unexpected (non-declared) exception during invocation of method
"getEmployeesByLastName"
on bean
"BeanId(eXpertsEAR#PayrollInternalServiceEJB.jar#EmployeeService,
null)". Exception data: <openjpa-1.0.3-SNAPSHOT-r420667:646455 nonfatal
general error> org
..apache.openjpa.persistence.PersistenceException: ORA-01424: missing or
illegal character following the escape character
{prepstmnt 337122328

The query generated by JPA:

SELECT t0.OID, t0.VERSION, t0.MODIFIED_BY_USER, t0.MODIFIED_ON, t0.AOID,
t0.BIRTH_DATE, t0.FIRST_NAME, t0.HIRE_DATE, t0.LAST_NAME,
t0.UNIQUE_ID
FROM EMPLOYEE t0
WHERE (UPPER(t0.LAST_NAME) LIKE ? ESCAPE '\')
[params=(String) \]} [code=1424, state=22025]

at
org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.
java:3951)
at
org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:97
)
at
org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:83
)
at
org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:59
...etc

Reference is EJB3 persistence specification section 4.6

[{"Product":{"code":"SSEQTP","label":"WebSphere Application Server"},"Business Unit":{"code":"BU048","label":"IBM Software"},"Component":"Java Persistence API (JPA)","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF012","label":"IBM i"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"7.0.0.3;7.0.0.1;7.0;6.1.0.2","Edition":"Feature Pack for EJB 3.0;Network Deployment;Single Server","Line of Business":{"code":"LOB77","label":"Automation Platform"}}]

Log InLog in to view more of this document

This document has the abstract of a technical article that is available to authorized users once you have logged on. Please use Log in button above to access the full document. After log in, if you do not have the right authorization for this document, there will be instructions on what to do next.

Document Information

More support for:
WebSphere Application Server

Software version:
7.0.0.3, 7.0.0.1, 7.0, 6.1.0.2

Operating system(s):
AIX, HP-UX, IBM i, Linux, Solaris, Windows

Document number:
622021

Modified date:
03 March 2025

UID

swg21377271

Manage My Notification Subscriptions