我正在尝试这样做:
public List getInventarioNode(){
String sql = "select n.nid, n.nnm, n.nhwtype, n.nstate, n.ipaddress, n.ipaddressrouterid, n.eswversion, u.unhwtype, u.unslot, m.mpos, m.mhwtype from node n, unit u, module m where n.nid*=u.nid and n.nid*=m.nid and u.nid*=m.nid and u.unnr*=m.unnr and n.nhwtype in (10020, 10021, 10022, 10023, 10002, 10017, 10001) and m.mpos not between 11 and 10000";
List resultWithAliasedBean = session.createSQLQuery(sql).setResultTransformer(Transformers.aliasToBean(Node.class)).list();
return resultWithAliasedBean;
}
但是我收到了这个错误:
11567 [AWT-EventQueue-0] ERROR org.hibernate.property.BasicPropertyAccessor - HHH000123: IllegalArgumentException in class: br.com.model.Node, setter method of property: mpos
11568 [AWT-EventQueue-0] ERROR org.hibernate.property.BasicPropertyAccessor - HHH000091: Expected type: java.lang.Integer, actual value: java.lang.Short
Exception in thread "AWT-EventQueue-0" IllegalArgumentException occurred while calling setter for property [br.com.model.Node.mpos (expected type = java.lang.Integer)]; target = [br.com.model.Node@18f6f48], property value = [0]
节点类:
//我试图将mpos和mhwtype的类型更改为int,但它没有用,因为第一行为null。在数据库中,两者都是smallint,可以为null。
private Integer mpos;
private Integer mhwtype;
public Node(){}
public Integer getMpos() {
return mpos;
}
public void setMpos(Integer mpos) {
this.mpos = mpos;
}
public Integer getMhwtype() {
return mhwtype;
}
public void setMhwtype(Integer mhwtype) {
this.mhwtype = mhwtype;
}