为什么我无法保存外键的值
<hibernate-mapping>
<class name="org.vo.Type" table="type">
<id name="typeid" type="java.lang.Integer">
<column name="typeid" />
<generator class="native" />
</id>
<property name="typename" type="java.lang.String">
<column name="typename" length="50" not-null="true" />
</property>
<set name="xuqius" inverse="true" cascade="all"
table="xuqiu" lazy="true" order-by="typeid">
<key>
<column name="typeid"/>
</key>
<one-to-many class="org.vo.Xuqiu" />
</set>
</class>
</hibernate-mapping>
private Integer typeid;
private String typename;
private Set xuqius;
<hibernate-mapping>
<class name="org.vo.Xuqiu" table="xuqiu">
<id name="id" type="java.lang.Integer">
<column name="id" />
<generator class="native" />
</id>
<many-to-one name="type" class="org.vo.Type">
<column name="typeid"/>
</many-to-one>
<property name="name" type="java.lang.String">
<column name="name" length="50" not-null="true" />
</property>
<property name="xuqiu" type="java.lang.String">
<column name="xuqiu" length="2000" not-null="true" />
</property>
<property name="fdate" type="java.lang.String">
<column name="fdate" length="23" />
</property>
<property name="gdate" type="java.lang.String">
<column name="gdate" length="23" />
</property>
<property name="state" type="java.lang.Integer">
<column name="state" />
</property>
</class>
</hibernate-mapping>
private Integer id;
private Integer typeid;
private String name;
private String xuqiu;
private String fdate;
private String gdate;
private Integer state;
private Type type;
在action中
XuqiuForm xuqiuForm = (XuqiuForm) form;
Xuqiu xuqiu = new Xuqiu();
xuqiu.setName(xuqiuForm.getName());
System.out.println(xuqiuForm.getName());
Type t = new Type();
t.setTypeid(Integer.getInteger(xuqiuForm.getType()));
xuqiu.setType(t);
System.out.println(xuqiuForm.getType());
xuqiu.setTypeid(Integer.getInteger(xuqiuForm.getType()));
xuqiu.setXuqiu(xuqiuForm.getXuqiu());
System.out.println(xuqiuForm.getXuqiu());
xuqiu.setFdate(xuqiuForm.getFdate());
System.out.println(xuqiuForm.getFdate());
xuqiu.setGdate(xuqiuForm.getGdate());
System.out.println(xuqiuForm.getGdate());
xuqiu.setState(Integer.getInteger(xuqiuForm.getState()));
System.out.println(xuqiuForm.getState());
try {
this.ixuqiudao.Save(xuqiu);
} catch (Exception e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
typeid为null 但是我System.out显示了值