【发布时间】:2014-05-31 04:41:54
【问题描述】:
我正在使用eclipseLink 2.4.1、JPA 2.0.1 和其他支持工具开发网络服务。我创建了一个包含日期类型列的表。我想获取特定日期的记录。我正在使用 mysql 的 date_format 并收到以下错误:
java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager:
Exception Description: Syntax error parsing[select o from Clients o where FUNCTION('date_format',{o.effectiveStartDate},{d,'dd-mm-yyyy'})='27-05-2014']
[90, 111] The JDBC escape format does not start with either 'd', 't' or 'ts'.
[110, 110] The JDBC escape format is missing the close quote.
即使我尝试直接调用 date_format 为:
Select o from Clients o where date_format(o.effectiveStartDate '%d-%m-%Y'})='27-05-2014'
然后我得到语法错误解析。 invalid token [(].
我也尝试了 namedQuery,但没有成功。
JPQL如何调用此类函数。
【问题讨论】:
-
嗨,梅赫迪洛菲。感谢您的编辑并使其更具可读性。我是新手,我该如何进行这种格式化。
标签: mysql jakarta-ee jpa eclipselink