@Test
public void testSaveStudents(){
//生成学生对象
Students s1 = new Students();//注意顺序
s1.setSname("试试");
s1.setGender("女");
s1.setBirthday(new Date());
Address address = new Address("6130","63302","大第县");
s1.setAddress(address);
session.save(s1);
}
因为最初运行时显示:could not parse mapping document from resource Students.hbm.xml.然后下面显示是由于:class Address not found while looking for property:postcode. 在网上找了解决方法,就在后面加了类型。但是依然会报错:
Unable to instantiate default tuplize org.hibernate.tuple.entity.PojoEntityTuplizer].
<component name="address" class="Address" >
<property name="postcode" column="POSTCODE" type="java.lang.String"/>
<property name="phone" column="PHONE" type="java.lang.String"/>
<property name="address" column="ADDRESS" type="java.lang.String"/>
</component>
我也遇到这样的问题了 感谢走在前面的巨人们!
谢谢了!!!真是被这个问题给气死了!!终于解决了
我知道了,是class="com.imooc.students.Address"
怎么加的?
发现原因了,是因为找不到Address。 在class之后加上所在包名就可以了