问题描述
- UncategorizedSQLException异常原因
-
执行一条HQL语句:select t.myApp from myPageApp t where t.sysUser.id = ? and t.recordStatus = 1 and t.myApp.recordStatus = 1 ;然后就报了org.springframework.jdbc.UncategorizedSQLException异常,什么原因导致的?查了半天了,求助。
具体报错信息:
org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not execute query; uncategorized SQLException for SQL [select deskapp1_.id as id2_, deskapp1_.apptype as apptype2_, deskapp1_.count_url as count3_2_, deskapp1_.CREATE_TIME as CREATE4_2_, deskapp1_.default_page as default5_2_, deskapp1_.depicts as depicts2_, deskapp1_.PARENT_ID as PARENT20_2_, deskapp1_.desk_icon_id as desk21_2_, deskapp1_.module_id as module22_2_, deskapp1_.ISAPP as ISAPP2_, deskapp1_.isdefault as isdefault2_, deskapp1_.isload as isload2_, deskapp1_.isresize as isresize2_, deskapp1_.NAME as NAME2_, deskapp1_.news_address as news12_2_, deskapp1_.news_height as news13_2_, deskapp1_.news_width as news14_2_, deskapp1_.page_percent as page15_2_, deskapp1_.RECORD_ORDER as RECORD16_2_, deskapp1_.RECORD_STATUS as RECORD17_2_, deskapp1_.sys_config_id as sys23_2_, deskapp1_.UPDATE_TIME as UPDATE18_2_, deskapp1_.url_address as url19_2_ from desk_page_app deskpageap0_ inner join desk_app deskapp1_ on deskpageap0_.desk_menu_id=deskapp1_.id where deskpageap0_.user_id=? and deskpageap0_.record_status=1 and deskapp1_.RECORD_STATUS=1]; SQL state [null]; error code [0]; Couldn't perform the operation prepareStatement: You can't perform any operations on this connection. It has been automatically closed by Proxool for some reason (see logs).; nested exception is java.sql.SQLException: Couldn't perform the operation prepareStatement: You can't perform any operations on this connection. It has been automatically closed by Proxool for some reason (see logs).
解决方案
SQL 查询语句异常
把语句复制进去数据库中执行看看
解决方案二:
elect t.myApp from myPageApp t where t.sysUser.id = ? and t.recordStatus = 1 and t.myApp.recordStatus = 1
这下面两个字段没看明白,什么样的字段呢,是不是写错了
t.sysUser.id
t.myApp.recordStatus = 1
解决方案三:
是对象, t是myPageApp对象,t里面又定义有SysUser类型对象,id是sysUser的属性,后面那个类似
解决方案四:
上面的回复中我写错了表名,下面才是我真实执行的语句:
HQL:select t.deskApp from DeskPageApp t where t.sysUser.id = 5 and t.recordStatus = 1 and t.deskApp.recordStatus = 1 ;
改成sql语句:
select t.desk_menu_id from Desk_Page_App t inner JOIN desk_app d on t.record_Status = 1 and d.record_Status = 1 and t.User_id = 5;
没有报错,
但为什么在程序中会报错?
解决方案五:
HQL查询?你确定你的HQL映射关系是正确的吗?
解决方案六:
OutOfMemonryException异常的原因有哪些
解决方案七:
多谢大家热心的解答,问题已解决。
时间: 2025-01-21 09:05:57