hibernate 查询的问题
我的程序代码如下:
session = HibernateUtil.currentSession();
tx=session.beginTransaction();
Query query=session.createQuery( "from BATCH_TBL ");
List batchTbls=query.list();
for(int i=0;i <batchTbls.size();++i)
{
batchTbl=(BatchTbl)batchTbls.get(i);
System.out.println( "ID: "+batchTbl.getBatchId());
}
//此时p1已经可以在数据库中找到
tx.commit();
HibernateUtil.closeSession();
这段代码执行时出现如下异常:
Hibernate: select from
net.sf.hibernate.exception.
GenericJDBCException: Could not execute query
at net.sf.hibernate.exception.SQLStateConverter.handledNonSpecificExcept
ion(SQLStateConverter.java:80)
at net.sf.hibernate.exception.SQLStateConverter.convert(SQLStateConverte
r.java:69)
at net.sf.hibernate.exception.
JDBCExceptionHelper.convert(JDBCExceptionH
elper.java:29)
at net.sf.hibernate.impl.SessionImpl.convert(SessionImpl.java:4131)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1557)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:49)
at cfchina.hiber.buzutil.TestDataQuery.queryAllDataFromDB(TestDataQuery.
java:154)
at cfchina.hiber.action.TestHiberAction.queryAllRecord(TestHiberAction.j
ava:107)
at cfchina.hiber.action.TestHiberAction.process(TestHiberAction.java:49)
at cfchina.hiber.action.CRFAction.perform(CRFAction.java:62)
at org.apache.struts.action.Action.execute(Action.java:420)
at org.apache.struts.action.RequestProcessor.processActionPerform(Requ