zoukankan      html  css  js  c++  java
  • JPA @Query ERROR. token : WHERE

    在使用中,发现了一个JPA的bug。

    错误:ERROR. token : WHERE

    我在Dao层,使用@Query时,使用了jpa的Pageable分页。

    @Query(value = "select * from Order where refSONo=:refSONo and IsValid = 1 /*#pageable*/", nativeQuery = true)
        Page<Order> findPagedList(@Param("refSONo") String refSONo, Pageable pageable);

    当执行时,会出现2个sql语句。

    1 select * from Order where refSONo=:refSONo and IsValid = 1 外加page分页 

    2 会查询总数  select count(where) from Order where refSONo=:refSONo and IsValid = 1

    但是很奇怪,查询总数时使用了count(where),导致报错:ERROR. token : WHERE

    这应该是JPA正则匹配的一个Bug。

    解决方案:where 换行

    @Query(value = "select * from Order "+
    " where refSONo=:refSONo and IsValid = 1 /*#pageable*/", nativeQuery = true)
        Page<Order> findPagedList(@Param("refSONo") String refSONo, Pageable pageable);

    总结:通过换行产生的 可以正确的引导正则匹配。

  • 相关阅读:
    所有选择器
    display:block、display:inline与displayinline:block的概念和区别
    jQuery 选择器
    JS日历制作获取时间
    HTML DOM 事件
    访问HTML元素(节点)
    HTML常用标签
    flask+mysql的Docker 部署
    docker(三)
    flask如何部署
  • 原文地址:https://www.cnblogs.com/hanjun0612/p/13071790.html
Copyright © 2011-2022 走看看