【hibernate】a different object with the same identifier value was already associated with the session:

Photon 发布于 2013/08/15 11:29
阅读 906
收藏 0

任务表Task有2字段:发起人launcher,值班人duty,他们都跟User表一对一关联,现在发现如果他们都是同一个人hibernate会抛异常:

org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [com.test.entity.User#2]

数据库没建立主外键约束,只有注解:

@OneToOne(cascade=CascadeType.ALL, fetch=FetchType.EAGER)
@JoinColumn(name="launcher")
private User		launcher;			//任务发起人	
@OneToOne(cascade=CascadeType.ALL, fetch=FetchType.EAGER)
@JoinColumn(name="duty")
private User		duty;				//值班人员
多谢~~
加载中
返回顶部
顶部