-->
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 join
PostPosted: Tue Nov 14, 2006 6:20 pm 
Newbie

Joined: Tue Nov 14, 2006 6:12 pm
Posts: 1
I am trying to map the standard User-Role relationship. The roles are keep in a table with a roleId. This is a static list of roles. The user can have many roles. I have a join table that tracks the user to his roles. I am using the following mapping on the User object to populate the roles:

Code:
<set name="roles" table="tb_subtype_info" lazy="false" cascade="all">
   <key column="sub_id"/>
   <many-to-many
            column="cnbc_subscriber_type_id"
            unique="true"
            class="com.ge.nbc.cnbc.svc.businessobjects.SubscriberType"/>
</set>


This mapping works fine when I query a user. The problem I am having is when I update or create a user an extra update is performed against the Role table even though this table did not change.

Is there any way to eliminate this relationship?

Thanks,
Pete


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 15, 2006 7:50 am 
Newbie

Joined: Thu Nov 02, 2006 8:41 am
Posts: 13
Location: Argentina
hi

you have a concept error, you have mapping yours objects thinking in relational model, when you have objects, you have to generate your object model and then map it. you have generate first your data model and then you map it, it's no so fine.

but to solve your problem you can't map your model with many-to-many.

when your relational model is like that

Table1<->relationalManyToMany<->Table2

you have to create then middle object and then map
ObjectTable1 one-to-many MiddleObject
and
ObjectTable2 one-to-many MiddleObject

I hope it help you


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.