Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am trying use the following following query using JPARepository but it is throwing

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

exception.

Here is the named query I have:

@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)"
)
like image 559
Elias Avatar asked Oct 17 '25 11:10

Elias


1 Answers

atlast I found the solution, I have enabled nativeQuery and return type change to 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();
like image 102
Elias Avatar answered Oct 19 '25 00:10

Elias