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
Log InLog in to view more of this document
Was this topic helpful?
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