我想獲得與月列完全匹配的記錄(這是id列),但我沒有得到匹配的記錄..我執行在SQL數據庫這樣的查詢「選擇Web表格,其中一個月=‘二月’表」是executed.In HQL它不工作..休眠提供以下錯誤:錯誤 - >無法執行查詢
我stackflow:
INFO: table found: soft.dbo.employee
SHEET DAO CLASS
Nov 18, 2011 12:57:12 PM org.hibernate.tool.hbm2ddl.TableMetadata <init>
Retrieve Sheet:::::::Feb
INFO: columns: [empid, time, empname]
Nov 18, 2011 12:57:12 PM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: foreign keys: []
Nov 18, 2011 12:57:12 PM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: indexes: [pk__employee__73a521ea]
Nov 18, 2011 12:57:12 PM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: table found: soft`enter code here`.dbo.webSheet
Nov 18, 2011 12:57:12 PM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: columns: [month, sheet]
Nov 18, 2011 12:57:12 PM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: foreign keys: []
Nov 18, 2011 12:57:12 PM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: indexes: [pk__websheet__69279377]
Nov 18, 2011 12:57:12 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: schema update complete
Hibernate: select websheet0_.sheet as col_0_0_ from webSheet websheet0_ where websheet0_.month=Feb
Error-->could not execute query
In opensheet class-->result
Nov 18, 2011 12:57:13 PM org.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: 207, SQLState: S0001
Nov 18, 2011 12:57:13 PM org.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: Invalid column name 'Feb'.
我的代碼如下:DataAccessDAO .java
try{
Session session=sessionFactory.openSession();
WebSheet ws=new WebSheet();
ws.setMonth(month);
txn=session.beginTransaction();
query=session.createQuery("select ws.sheet from WebSheet as ws where ws.month="+month).list();
System.out.println("result::::::::::"+query.size());
String result=query.iterator().next().getSheet();
}
catch(Exception ex){
System.err.println("Error-->"+ex.getMessage());
if(txn!=null){
txn.rollback();
}
}
我的映射文件:
<hibernate-mapping>
<class name="com.MyApp.beans.WebSheet" table="webSheet">
<id name="month" type="string">
<generator class="assigned"/>
</id>
<property name="sheet" type="string"/>
</class>
</hibernate-mapping>
我的POJO類:
public class WebSheet {
private String month;
private String sheet;
/*setters and getters*****
謝謝你的回覆。現在給出以下錯誤。錯誤 - > java.lang.String不能轉換爲com.MyApp.beans.WebSheet – javan
我已經改變了我的答案,現在檢查。 –