Reputation: 99
I am new to jpa and trying to write a query. Query is related to enum. I have an enum, I want to fetch records based on enum.
In below query deviceStatus is an enum. when I defined lk.deviceStatus =LOCKER_CLOSE giving error:
Unknown column 'LOCKER_CLOSE' in 'where clause'
@Query("SELECT lk from Locker lk where lk.terminal.id=:terminalId
and lk.deviceStatus =LOCKER_CLOSE and lk.isEmpty =true
and :size IS NULL OR lk.lockerSize=:size")
public List<Locker> testOneFunction(@Param("terminalId") String
terminalId, @Param("size") LockerSize size);
Upvotes: 0
Views: 713
Reputation: 148
Try using fully qualified enum class e.g.
SELECT lk from Locker lk where lk.terminal.id=:terminalId
and lk.deviceStatus = com.somepackage.MyStatusEnum.LOCKER_CLOSE
and lk.isEmpty =true and :size IS NULL OR lk.lockerSize=:size
Upvotes: 1