hibernate 异常a different object with the same identifier value was already associated with the session:
大家见过这个异常么???
一个简单的多对多关系,产品的分类的关系,
为第一个产品添加全部分类完全正常,
当给二个产品添加全部分类的时候出现异常,只能给第二个产品添加一个分类,不能给第二产品添加任意两个分类,只能添加一个。
产品配置
<set
cascade="save-update"
name="ProtypeSet"
table="protypeline"
>
<key column="proId" />
<many-to-many class="Protype" column="typeId" />
</set>
-----------------------------------------------------------------------
类别配置
<set
cascade="save-update"
name="ProductSet"
table="protypeline"
>
<key column="typeId" />
<many-to-many class="Product" column="proId" />
</set>
------------------------------------------------------------------------------
大家帮忙看看有错误么?
这是错误:
a different object with the same identifier value was already associated with the session: 8, of class: com.onizuka.mall.Product