[英]How to not replace named parameters in EntityManager.createNativeQuery()?
I am using JBOSS AS 7 and I have to use this command prior to querying: 我正在使用JBOSS AS 7,在查询之前必须使用以下命令:
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. 现在,如果我启动此查询,将显示错误消息“尚未设置所有命名参数:[MI:SS]”。 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. 我还尝试将“参数”“ MI”设置为MI,将“ SS”设置为SS,但这都没有帮助。
How can I fire this query up without Hibernate trying to replace the named parameters? 如何在没有Hibernate尝试替换命名参数的情况下启动此查询? Or how can I set this information globally in the application server resp.
或者,如何在应用程序服务器响应中全局设置此信息。 in the persistence.xml or the standalone.xml from JBOSS?
在JBOSS的persistence.xml或standalone.xml中?
Try with single quotes: 尝试使用单引号:
String sql = "alter session set nls_date_format='YYYY-MM-DD HH24:MI:SS'";
entityManager.createNativeQuery(sql);
您是否尝试过这样的转义:
"alter session set nls_date_format='YYYY-MM-DD HH24:MI:SS'"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.