ORA-00923: 未找到预期 FROM 关键字 的问题,求助
代码如下:
public List getForumMainList(final long bid, final int firstResult, final int maxResults) {
return getHibernateTemplate().executeFind(new HibernateCallback() {
public Object doInHibernate(Session s) throws
HibernateException,
SQLException {
String q = "from Forum " + SysUtil.getForumTableID(bid) +
" forum where forum.boardID = ? and forum.isNew = 1 and forum.delSign = 0 and forum.auditing = 0 order by forum.isTop desc,forum.lastTime desc ";
Query query = s.createQuery(q);
query.setLong(0, bid);
query.setFirstResult(firstResult);
query.setMaxResults(maxResults);
List list = query.list();
return list;
}
}
);
}
错误信息
2007-02-15 14:13:58,859 [org.springframework.jdbc.support.SQLStateSQLExceptionTranslator]-[INFO] Translating SQLException with SQLState '42000 ' and errorCode '923 ' and message [ORA-00923: 未找到预期 FROM 关键字
]; SQL was [null] for task [HibernateAccessor]
2007-02-15 14:13:58,875 [org.apache.struts.action.RequestProcessor]-[WARN] Unhandled Exception thrown: class
org.springframework.jdbc.BadSqlGrammarException 2007-02-15 14:13:58,875 [org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/bbs]]-[INFO] Bad SQL grammar [null] in task 'HibernateAccessor '; nested exception is
java.sql.SQLException: ORA-00923: 未找到预期 FROM 关键字
请问是什么问题,明天还有一天了就要完成,急啊,帮忙啊各位
------解决方案--------------------老兄细心点就行了
String q = "from Forum " + ... 改为
String q = "select Forum " +...
------解决方案--------------------String q = "from Forum " + SysUtil.getForumTableID(bid) +
" forum where forum.boardID = ? and forum.isNew = 1 and forum.delSign = 0 and forum.auditing = 0 order by forum.isTop desc,forum