hibernate 奇怪问题
我的vo是这样的 staff.java
===============================================
private Integer num;
private String id;
private String name;
private String pass;
private String qx;
private String tel;
private String address;
================================================
staffDaoImpl里有这么个函数
public Staff queryById(String id) {
// TODO Auto-generated method stub
Staff staff = null;
String hql = "FROM Staff AS n WHERE n.id=?";
Query q = session.createQuery(hql);
q.setString(0, id);
List all = q.list();
if(all.size() > 0) {
staff = (Staff)all.get(0);
}
session.close();
return staff;
}
=====================================================
main函数
public static void main(String[] args){
StaffDaoImpl s = new StaffDaoImpl();
String pass = s.queryById("admin").getPass();
System.out.print(pass);
}
======================================================
hibernate输出的sql 语句却为:
Hibernate: select staff0_.num as num, staff0_.id as id0_, staff0_.name as name0_, staff0_.pass as pass0_, staff0_.qx as qx0_, staff0_.tel as tel0_, staff0_.address as address0_ from jxc.staff staff0_ where staff0_.num=?
为什么是staff0_.num啊,我明明用的是id啊,而且别的字段都可以,就id变成了num????
下面是配置文件
<hibernate-mapping>
<class name="com.ln.vo.Staff" table="staff" catalog="jxc">
<id name="num" type="java.lang.Integer">
<column name="num" />
<generator class="assigned" />
</id>
<property name="id" type="java.lang.String">
<column name="id" length="50" not-null="true" />
</property>
<property name="name" type="java.lang.String">
<column name="name" length="50" />
</property>
<property name="pass" type="java.lang.String">
<column name="pass" length="50" />
</property>
<property name="qx" type="java.lang.String">
<column name="qx" length="100" />
</property>
<property name="tel" type="java.lang.String">
<column name="tel" length="50" />
</property>
<property name="address" type="java.lang.String">
<column name="address" length="11" />
</property>
</class>
</hibernate-mapping>