问题:
org.hibernate.PropertyNotFoundException Could not find a getter for id in class com.lnzkx.model.ChildUser
解决:
在ChildUser.hbm.xml里主键设置错误
改前代码
<hibernate-mapping>
<class name="com.lnzkx.model.ChildUser" table="childUser">
<id name="id" column="id" type="long">
<!-- 主键的生成方式 increment自增方式-->
<generator class="increment"></generator>
</id>
<property name="userId" column="userId" type="long"></property>
<property name="childUserName" column="childUserName" type="string"></property>
<property name="childPassword" column="childPassword" type="string"></property>
<property name="childUserEmail" column="childUserEmail" type="string"></property>
</class>
</hibernate-mapping>
改后代码
<hibernate-mapping>
<class name="com.lnzkx.model.ChildUser" table="childUser">
<id name="childUserId" column="childUserId" type="long">
<!-- 主键的生成方式 increment自增方式-->
<generator class="increment"></generator>
</id>
<property name="userId" column="userId" type="long"></property>
<property name="childUserName" column="childUserName" type="string"></property>
<property name="childPassword" column="childPassword" type="string"></property>
<property name="childUserEmail" column="childUserEmail" type="string"></property>
</class>
</hibernate-mapping>
总结:
代码最好自己写,不要粘贴其他的该,一个不小心就有没改的,就错了。