我两条hql查询语句
hql1= "form article order by pubtime desc "
hql2= "form article order by visitcount desc "
其中, article 是 mysql数据库中的一张表
其字段和类型如下:
pubtime(datatime), content(varchar), id(integer),
title(varchar), sortid(integer), visitcount(integer)
有的可以为空,有的不为空,不过在数据库里,所有字段都是有值的
然后我通过 session.createQuery(hql);这条语句来执行上面的语句
但是结果是:hql1可以运行,而hql2不可以运行
其错误只要提示,如下:
20:47:27,875 DEBUG ErrorCounter:68 - throwQueryException() : no errors
20:47:27,937 DEBUG QueryTranslatorImpl:216 - HQL: from com.ukey.Blog.Article order by visitcount desc
20:47:27,937 DEBUG QueryTranslatorImpl:217 - SQL: select article0_.id as id2_, article0_.title as title2_, article0_.content as content2_, article0_.pubtime as pubtime2_, article0_.sortid as sortid2_, article0_.visitcount as visitcount2_ from article article0_ order by article0_.visitcount desc
20:47:27,937 DEBUG ErrorCounter:68 - throwQueryException() : no errors
20:47:28,031 DEBUG HQLQueryPlan:269 - HQL param location recognition took 31 mills (from Article order by visitcount desc)
20:47:28,125 DEBUG QueryPlanCache:76 - located HQL query plan in cache (from Article order by visitcount desc)
20:47:28,140 DEBUG HQLQueryPlan:150 - find: from Article order by visitcount desc
20:47:28,140 DEBUG QueryParameters:277 - named parameters: {}
20:47:28,171 DEBUG AbstractBatcher:366 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
20:47:28,171 DEBUG SQL:401 - select article0_.id as id2_, article0_.title as title2_, article0_.content as content2_, article0_.pubtime as pubtime2_, article0_.sortid as sortid2_, article0_.visitcount as visitcount2_ from article article0_ order by article0_.visitcount desc limit ?
Hibernate: select article0_.id as id2_, article0_.title as title2_, article0_.content as content2_, article0_.pubtime as pubtime2_, article0_.sortid as sortid2_, article0_.visitcount as visitcount2_ from article article0_ order by article0_.visitcount desc limit ?
20:47:28,171 DEBUG AbstractBatcher:484 - preparing statement
20:47:28,218 DEBUG AbstractBatcher:382 - about to open ResultSet (open ResultSets: 0, globally: 0)
20:47:28,234 DEBUG Loader:694 - processing result set
20:47:28,234 DEBUG Loader:699 - result set row: 0
20:47:28,234 DEBUG Loader:1173 - result row: EntityKey[com.ukey.Blog.Article#1]