sql中could not extract ResultSet 问题~
来源:互联网 发布:linux系统搭建 编辑:程序博客网 时间:2024/06/04 19:13
ResultSet org.hibernate.exception.SQLGrammarException: could not extract ResultSet 这个问题..一般是自己的sql写的有问题。
在ide里边使用原生的sql时,要格外注意~下边说一个在springboot jpa中遇到的问题。
这个是正确的sql:
@Query(value = "select * from `tb_announcement_mgmt`" + " where `title`=:title and `is_del`=0 " + "and (case when :areaCode=0 then 1=1 else `area_code`=:areaCode end) limit 10", nativeQuery = true)
两个错误的sql:
case1:@Query(value = "select * from `tb_announcement_mgmt`" + " where `title`=:title and `is_del`=0" + "and (case when :areaCode=0 then 1=1 else `area_code`=:areaCode end) limit 10", nativeQuery = true)case2:@Query(value = "select * from `tb_announcement_mgmt`" + " where `title`=:title and `is_del`=0 " + "and (case when :areaCode=0 then 1=1 " +"else `area_code`=:areaCode end) limit 10", nativeQuery = true)
emmmm…乍看起来是没有问题的~~但是.他就是有错的
第一个错误的地方在于:
” where title
=:title and is_del
=0”+ “and 在0和end之间 没有空格!! 。。。在执行sql的时候,ide将字符串拼成一个完整的sql,0和end之间没有空格,那么拼接的时候就会成为 where title
=:title and is_del
=0and (case 这样的格式,所以就报错了.
第二个错误的地方在于:
“and (case when :areaCode=0 then 1=1 “+”else area_code
=:areaCode end) 这句汇总case else 是一个完整的语句,在一个括号中,是不能分开的..所以要写成
“and (case when :areaCode=0 then 1=1 else area_code
=:areaCode end) 才是正确的。
~~有的问题就是要自己多注意了。
阅读全文
0 0
- sql中could not extract ResultSet 问题~
- could not extract ResultSet
- could not extract ResultSet
- SQLGrammarException: could not extract ResultSet
- hibernate异常:could not extract ResultSet
- org.hibernate.exception.SQLGrammarException: could not extract ResultSet
- org.hibernate.exception.SQLGrammarException: could not extract ResultSet
- org.hibernate.exception.SQLGrammarException: could not extract ResultSet
- org.hibernate.exception.SQLGrammarException: could not extract ResultSet
- org.hibernate.exception.SQLGrammarException: could not extract ResultSet at org.hibernate.exception.
- Hibernate抛出异常org.hibernate.exception.SQLGrammarException: could not extract ResultSet
- Caused by: org.hibernate.exception.SQLGrammarException: could not extract ResultSet 报错原因
- RestClientException: Could not extract response:
- 关于SQL server中不支持ResultSet.last() 的问题
- PL/SQL Developer 中的问题:Initialization error Could not load
- PL/SQL Developer 中的问题:Initialization error Could not load
- SQL extract
- 解决网站开发中ResultSet can not re-read row data for column问题
- Java--常见排序算法
- Apache JMeter 测试实例
- shell脚本监控cpu/内存使用率
- 并发编程之wait方法的理解
- No bean named 'standService' is defined] with root cause
- sql中could not extract ResultSet 问题~
- 联网游戏使用的同步技术
- Eclipse中改变编码方式及解决部分乱码问题
- Spring Boot 计划任务(定时任务)
- 442. Find All Duplicates in an Array
- python实现读取本地多个TXT文件内容并发送邮件
- ccf 2014 12 4最优灌溉
- Django配置数据库读写分离
- cxf下载客户端代码