`
greemranqq
  • 浏览: 967431 次
  • 性别: Icon_minigender_1
  • 来自: 重庆
社区版块
存档分类
最新评论

should be mapped with insert="false" update="false"

阅读更多

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>
 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics