日期:2014-05-20 浏览次数:20872 次
public List<Temprelation> findMaxCount(String ASId){ log.debug("find the Max Count Object "+ASId+" !"); String queryString = " from Temprelation t where t.id.songinfo.sid = "+ASId+" order by t.count desc"; Query queryObject = null; try { queryObject = getSession().createQuery(queryString); } catch (RuntimeException e) { log.error("find the Max Count Object "+ASId+" is failed!",e); throw e; } System.out.println("size= "+queryObject.list().size()); List<Temprelation> temp = queryObject.list(); List<Temprelation> list; if(temp.size()>=2) list = temp.subList(0,2); else list = temp; return list; }
Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not execute query at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66) at org.hibernate.loader.Loader.doList(Loader.java:2235) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2129) at org.hibernate.loader.Loader.list(Loader.java:2124) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401) at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363) at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196) at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1149) at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102) at HIBER.TemprelationDAO.findMaxCount(TemprelationDAO.java:77) at MySessionClass.TotalInfoBiz.GetMAXRelation(TotalInfoBiz.java:67) at MySessionClass.test2.main(test2.java:26) Caused by: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Unknown column 'fddfd' in 'where clause' at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723) at com.mysql.jdbc.Connection.execSQL(Connection.java:3283) at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1332) at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1467) at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208) at org.hibernate.loader.Loader.getResultSet(Loader.java:1812) at org.hibernate.loader.Loader.doQuery(Loader.java:697) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259) at org.hibernate.loader.Loader.doList(Loader.java:2232) ... 10 more