-->
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.  [ 2 posts ] 
Author Message
 Post subject: Many-to-Many Association - !!!!!!!Help!!!!!!!!!
PostPosted: Fri Jan 14, 2005 12:40 pm 
Newbie

Joined: Tue Dec 21, 2004 5:30 pm
Posts: 7
Dear All

I have problems in Many-to-Many association. Basically i have table "A" and table "B" and an association table "A-B". I have mapped both the Tables and mapped Many-to-Many association from A->B specifying the association table "A-B". When i insert records into table "A" with collection of "B" set in A, i want the table "A" and the association table "AB" to be affected. But, for me Hibernate updates the table "B" also..I don't want to do that..Because, table "B" is a Type table where in the Data is static.


Any help would be highly appreciated..

Find below the mapping iam using..

<bag
name="gradesTaughtList"
table="Teacher_Grades_Taught"
lazy="true"
inverse="true"
cascade="save-update"
>

<key
column="profile_id"
>
</key>

<many-to-many
class="com.harcourt.alamo.model.Grade"
column="grade_type_id"
outer-join="auto"
/>

</bag>


In the above mapping, i want the "Teacher_Grades_Taught" table to be updated, not the "Grade" table

Regards
Kaleel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 14, 2005 1:40 pm 
Regular
Regular

Joined: Tue Jun 22, 2004 8:01 pm
Posts: 106
Location: PowderTown, Utah, USA
You need to understand how updates are cascaded. Review the reference material about "cascade" options on collections. I suspect that if you change your "cascade" property to a value of "none" it will solve your problem. Think about it. If the grade type is truly immutable (only one instance in the whole system), you don't want any kind of update or delete change to cascade.

When I'm using immutable data that are actually just modelling "Types" in the system, I've found it helpful to use a custom UserType or a custom CompositeUserType (for more granular control). As you've seen, modelling immutable types as entities can have side-effects. But, it still should work.


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

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.