gpt4 book ai didi

java - org.hibernate.QueryException : unexpected char: '` '

转载 作者:行者123 更新时间:2023-11-29 06:46:41 25 4
gpt4 key购买 nike

我正在尝试使用 JPARepository 使用以下查询,但它抛出

org.hibernate.QueryException: unexpected char: '`' "

异常。

这是我的命名查询:

@NamedQuery(name = "shift_planner.fetchThisWeekShiftDetails",
query =
"SELECT r.resouce_name,s.shift_name,sp.plan_date
FROM elias.shift_planner sp, elias.resources r, elias.shifts s
WHERE sp.resource_id=r.resource_id and sp.shift_id=s.shift_id
AND YEARWEEK(`plan_date`, 1) = YEARWEEK(CURDATE(), 1)"
)

最佳答案

最后我找到了解决方案,我启用了nativeQuery并将返回类型更改为Object[]。

@Query( value="SELECT resouce_name,shift_name,plan_date FROM   elias.shift_planner sp, elias.resources r, elias.shifts s WHERE  sp.resource_id=r.resource_id and sp.shift_id=s.shift_id and YEARWEEK(`plan_date`, 1) = YEARWEEK(CURDATE(), 1)order by plan_date",nativeQuery = true)
List<Object[]> fetchThisWeekShiftDetails();

关于java - org.hibernate.QueryException : unexpected char: '` ',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49103669/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com