0

I am using JBOSS AS 7 and I have to use this command prior to querying:

entityManager.createNativeQuery(
    "ALTER SESSION SET NLS_DATE_FORMAT =\"YYYY-MM-DD HH24:MI:SS\"");

Now if I fire up this query the error message "Not all named parameters have been set: [MI:SS]" is shown. That makes sense, and I understand named parameters and everything. But just in this case I want this whole string not fiddled with.

I also tried to set the "parameter" "MI" to MI and "SS" to SS, but that did not help either.

How can I fire this query up without Hibernate trying to replace the named parameters? Or how can I set this information globally in the application server resp. in the persistence.xml or the standalone.xml from JBOSS?

easyDaMan
  • 308
  • 3
  • 8

2 Answers2

0

Try with single quotes:

String sql = "alter session set nls_date_format='YYYY-MM-DD HH24:MI:SS'";
entityManager.createNativeQuery(sql);
Federico Sierra
  • 5,118
  • 2
  • 23
  • 36
0

Have you tried escaping like this:

"alter session set nls_date_format='YYYY-MM-DD HH24:MI:SS'"
mendieta
  • 3,470
  • 2
  • 20
  • 23