-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: many-to-many Association being deleted
PostPosted: Mon Jul 18, 2005 4:23 pm 
Newbie

Joined: Mon Jul 18, 2005 4:16 pm
Posts: 1
Hi

I have two tables user and role and an intermediate table user_role. Here is my user.hbm.xml

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
<class name="User" table="USERS">
<id name="id" column="USER_ID">
<generator class="assigned"/>
</id>

<property name="lastName" column="LAST_NAME"/>
<property name="firstName" column="FIRST_NAME"/>
<property name="password" column="PASSWORD"/>
<property name="email" column="EMAIL"/>
<set name="roleAliases" table="USER_ROLE">
<key>
<column name="USER_ID" not-null="true"/>
</key>
<many-to-many class="RoleAlias">
<column name="ROLE_ALIAS_ID" not-null="true"/>
</many-to-many>
</set>

<many-to-one name="dept" column="DEPT_ID"/>
<set name="divs" table="USER_DIVISION">
<key>
<column name="USER_ID" not-null="true"/>
</key>
<many-to-many class="Division">
<column name="DIV_ID" not-null="true"/>
</many-to-many>
</set>
<property name="active" column="ACTIVE"/>
<property name="midName" column="MIDDLE_NAME"/>
</class>

</hibernate-mapping>

The user details are retrieved properly. But when I try to update an user, instead of updating the user_role table, it deletes the user data and inserts a new record. My user-role table can have multiple records with the same user id. So if I update the user, it deletes all the user records from the table. How do I force it to update the user_role table instead of delete/insert?

Thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.