hibernate多对多插入数据时覆盖上一次插入的数据;请问怎么办啊。
TABLEt_group<hibernate-mappingpackage="com.contact.domain"><classname="Group"table="t...
TABLE t_group
<hibernate-mapping package="com.contact.domain">
<class name="Group" table="t_group" >
<id name="id" type="integer">
<column name="id" />
<generator class="native" />
</id>
<property name="groupName" type="string">
<column name="groupname" />
</property>
<set name="contacts" table="t_contact_group" cascade="delete" >
<key column="group_id"></key>
<many-to-many class="Contact" column="contact_id"></many-to-many>
</class> 不想让数据覆盖
TABLE t_contact
<class name="Contact" table="t_contact" >
<id name="id" type="integer">
<column name="id" />
<generator class="native" />
</id>
<set name="groups" table ="t_contact_group" inverse="true" cascade="all-delete-orphan" >
<key column="contact_id"></key>
<many-to-many class="Group" column="group_id"></many-to-many>
</set> 展开
<hibernate-mapping package="com.contact.domain">
<class name="Group" table="t_group" >
<id name="id" type="integer">
<column name="id" />
<generator class="native" />
</id>
<property name="groupName" type="string">
<column name="groupname" />
</property>
<set name="contacts" table="t_contact_group" cascade="delete" >
<key column="group_id"></key>
<many-to-many class="Contact" column="contact_id"></many-to-many>
</class> 不想让数据覆盖
TABLE t_contact
<class name="Contact" table="t_contact" >
<id name="id" type="integer">
<column name="id" />
<generator class="native" />
</id>
<set name="groups" table ="t_contact_group" inverse="true" cascade="all-delete-orphan" >
<key column="contact_id"></key>
<many-to-many class="Group" column="group_id"></many-to-many>
</set> 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询