1
我有限定的本類BidToolTradeLanes如下:無法設置由反射設定器錯誤的字段值在休眠
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.catapult.bid.model;
/**
*
* @author Alok Shrestha
*/
public class BidToolTradeLanes {
private int tradeLaneId;
private String tradeLaneName;
private int contractId;
public BidToolTradeLanes() {
}
public int getContractId() {
return contractId;
}
public void setContractId(int contractId) {
this.contractId = contractId;
}
public int getTradeLaneId() {
return tradeLaneId;
}
public void setTradeLaneId(int tradeLaneId) {
this.tradeLaneId = tradeLaneId;
}
public String getTradeLaneName() {
return tradeLaneName;
}
}
而且,我有用於上述類這種映射文件:
<hibernate-mapping package="com.catapult.bid.model" default-access="field">
<class name="BidToolTradeLanes" table="bt_trade_lane" schema="bidtool" >
<id name="tradeLaneId" type="int" column="trade_lane_id">
<generator class="sequence">
<param name="sequence">bidtool.trade_lane_trade_lane_id_seq</param>
</generator>
</id>
<property name="tradeLaneName" type="string">
<column name="tradelane_name" length="20"/>
</property>
<many-to-one class="Contracts" fetch="select" name="contractId">
<column name="contract_id"/>
</many-to-one>
</class>
現在,每當我試圖運行此聲明,我得到的錯誤
List list=session.createSQLQuery("select {t.*} from bidtool.bt_trade_lane t")
.addEntity("t",BidToolTradeLanes.class).list();
我得到的錯誤是:
could not set a field value by reflection setter of com.catapult.bid.model.BidToolTradeLanes.contractId
您的幫助將不勝感激。