Exception:xxx (should be mapped with insert="false" update="false")
当你在映射文件中重复定义 么个字段的时候,就会有这个异常。我出现在many-to-one 中。
原因是:我配 1对1 外键双向关联的时候,属性ID重复。因为hibernate 将hibernate.hbm2ddl.auto=update 这样设置,会检查数据库字段,今天添加。。。,但你做外键关联的时候,你设置了个字段,那么就会强制你关闭这个。
<class name="com.home.entity.User" lazy="false" table="USER">
<id name="userId" column="UserId">
<generator class="uuid.hex" />
</id>
<property name="userName" column="UserName"/>
<property name="passWord" column="PassWord"/>
<many-to-one name="timesheet" class="com.home.timesheet.entity.TimesheetVOImpl" cascade="all">
<!-- 这里重复 -->
<column name="UserId"/>
</many-to-one>
</class>