select top(1) s.id from LocalSfgGyOperator s order by id desc错误信息
2009-01-08 09:34:56,031 [org.hibernate.hql.PARSER]-[ERROR] line 1:15: unexpected token: s
2009-01-08 09:34:56,046 [org.apache.struts.action.RequestProcessor]-[WARN] Unhandled Exception thrown: class org.springframework.orm.hibernate3.HibernateQueryException
2009-01-08 09:34:56,046 [org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/FstERP]]-[INFO] unexpected token: s near line 1, column 15 [select top(1) s.id from net.fst.erp.dbmap.LocalSfgGyOperator s order by id desc]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: unexpected token: s near line 1, column 15 [select top(1) s.id from net.fst.erp.dbmap.LocalSfgGyOperator s order by id desc]
2009-01-08 09:34:56,031 [org.hibernate.hql.PARSER]-[ERROR] line 1:15: unexpected token: s
2009-01-08 09:34:56,046 [org.apache.struts.action.RequestProcessor]-[WARN] Unhandled Exception thrown: class org.springframework.orm.hibernate3.HibernateQueryException
2009-01-08 09:34:56,046 [org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/FstERP]]-[INFO] unexpected token: s near line 1, column 15 [select top(1) s.id from net.fst.erp.dbmap.LocalSfgGyOperator s order by id desc]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: unexpected token: s near line 1, column 15 [select top(1) s.id from net.fst.erp.dbmap.LocalSfgGyOperator s order by id desc]
Query q = Session.createQuery(hql);LocalSfgGyOperator entity = (LocalSfgGyOperator)q.setMaxResults(1).list().get(0);int id = entity.getId();
Query q = Session.createQuery(hql); LocalSfgGyOperator entity = (LocalSfgGyOperator)q.setMaxResults(1).list().get(0); int id = entity.getId();
unexpected token: s
select top(1) s.id from LocalSfgGyOperator s order by id desc 中的 LocalSfgGyOperator s 不识别。
换一下:
select top(1) LocalSfgGyOperator.id from LocalSfgGyOperator order by LocalSfgGyOperator.id desc