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);

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

  • 相关阅读:
    phpcms 的getcache()函数
    git 上配置公钥
    linux 上git安装
    mac上php的扩展yaf安装
    Linux常用指令---grep(搜索过滤)
    mac virtualbox+vagrant安装
    nginx配置location及rewrite规则重写
    mac php环境搭建
    nginx.pid丢失问题
    git操作教程详解
  • 原文地址:https://www.cnblogs.com/hanjun0612/p/13071790.html
Copyright © 2011-2022 走看看