亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

different object with the same identifier value was already associated with the session

出現了如圖的錯誤http://img1.sycdn.imooc.com//56f225ac0001a83f12800800.jpg

當刪掉session.save(stu2)的時候就沒有錯誤了,如何在不刪掉stu2的情況下解決

正在回答

2 回答

把Student.hbm.xml和Grade.hbm.xml文件中id的generator class 改成=increment 或者是native

??<class?name="entity.Grade"?table="GRADE">
????????<id?name="gid"?type="java.lang.Integer">
????????????<column?name="GID"?/>
????????????<!--這里-->
????????????<generator?class="increment"?/>


0 回復 有任何疑惑可以回復我~

可以貼下源碼不

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消
Hibernate初探之一對多映射
  • 參與學習       42160    人
  • 解答問題       310    個

Hibernate中一對多關聯映射配置,以及cascade和inverse屬性作用

進入課程

different object with the same identifier value was already associated with the session

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號