java.lang.String cannot be cast to java.lang.Long
在hbm.xml文件里面:
把long改成string就好了。
<property name="homeNumber" column="homeNumber" type="long"></property>
<property name="workNumber" column="workNumber" type="string"></property>
<property name="mobileNumber" column="mobileNumber" type="string"></property>
<property name="linkmanNumber" column="linkmanNumber" type="string"></property>
attempted to assign id from null one-to-one property:
Customer ss = new Customer(200,"man32","广州");
Number number1 = new Number("34234","","54545","345335");
ss.setNumber(number1);//这里两个对象要互相插入,只有其中一个是不行的。
number1.setCustomer(ss);
session.save(ss);//保存的顺序也有影响,因为Numer是把Customer的主键当自己的外键,从而建立自己的主键的值,所以应该先保存Customer的值再保存Number.
session.save(number1);