Hibernate 查询语法错误: unexpected token: * - 解决方法
Hibernate 查询语法错误: unexpected token: * - 解决方法
异常报告:
消息 'unexpected token: * near line 1, column 37 [ from com.hdfix.model.Papers where * order by id desc ]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: unexpected token: * near line 1, column 37 [ from com.hdfix.model.Papers where * order by id desc ]
描述: 服务器遇到了一个意外的情况,阻止它完成请求。
例外情况:
org.springframework.orm.hibernate3.HibernateQueryException: unexpected token: * near line 1, column 37 [ from com.hdfix.model.Papers where * order by id desc ]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: unexpected token: * near line 1, column 37 [ from com.hdfix.model.Papers where * order by id desc ]
org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:660)
org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:411)
org.springframework.orm.hibernate3.HibernateTemplate.executeFind(HibernateTemplate.java:343)
com.hdfix.dao.impl.PapersDaoImpl.selectBeanList(PapersDaoImpl.java:43)
com.hdfix.action.PaperAction.index(PaperAction.java:198)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)
报错解决内容:
根据异常报告,出现了一个意外的情况,导致服务器无法完成请求。异常报告中显示的错误是在查询语句中出现了意外的标记“*”,导致语法错误。
要解决这个问题,需要检查查询语句并修复语法错误。在这种情况下,将查询语句中的“*”替换为正确的列名或使用合适的查询语法来选择需要的列。
修复后的查询语句可能如下所示:
from com.hdfix.model.Papers order by id desc
修复后,重新部署应用程序并测试是否解决了异常。
原文地址: https://www.cveoy.top/t/topic/fAUS 著作权归作者所有。请勿转载和采集!