我的存储库中有nativeQuery查询。
@Query(value = Constant.QUERY_FIND_GUIDE, nativeQuery=true)
List<Guide> findGuide(String locationName, String gender, String type, String language);
和Constant.QUERY_FIND_GUIDE是
public static final String QUERY_FIND_GUIDE = "SELECT g.id FROM Guide g " +
" LEFT JOIN g.user u " +
" LEFT JOIN g.locations l " +
" LEFT JOIN g.languages lang "+
"WHERE (UPPER(?1)=UPPER('NULL') OR ?1 IS NULL OR ?1 ='' OR l.locationName = ?1) "
+ " AND (UPPER(?2)=UPPER('NULL') OR ?2 IS NULL OR ?2 ='' OR g.gender =?2) "
+ " AND (?3 IS NULL OR ?3 ='' OR "
+ " (CASE WHEN UPPER(?3)=UPPER('NULL') THEN g.cardnumber IS NULL ELSE g.cardnumber IS NOT NULL END) )"
+ " AND (UPPER(?4)=UPPER('NULL') OR ?4 IS NULL OR ?4='' OR lang.language = ?4)";
当我运行页面时,我收到此错误:
2018-04-24 03:05:32.198 WARN 1340 --- [nio-8080-exec-4] o.h.engine.jdbc.spi.SqlExceptionHelper:SQL错误:1064,SQLState:42000 2018-04-24 03:05:32.198 ERROR 1340 --- [nio-8080-exec-4] o.h.engine.jdbc.spi.SqlExceptionHelper:你的SQL语法有错误;查看与您的MySQL服务器版本对应的手册,以便在'WHERE(UP'('Ha Noi')= UPPER('NULL')或'Ha Noi'IS NULL或'Ha Noi'=''附近使用正确的语法第1行 2018-04-24 03:05:32.208 ERROR 1340 --- [nio-8080-exec-4] c.w.tgo.controller.OperatorController: 错误搜索:org.springframework.dao.InvalidDataAccessResourceUsageException:无法提取ResultSet; SQL [不适用];嵌套异常是org.hibernate.exception.SQLGrammarException:无法提取ResultSet
我在谷歌上尝试所有解决方案,但无法修复它。有人能帮帮我吗?