-->
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.  [ 3 posts ] 
Author Message
 Post subject: Hibernate | Many to many mapping | problem in add and delete
PostPosted: Sat Oct 01, 2011 12:23 am 
Newbie

Joined: Sat Oct 01, 2011 12:15 am
Posts: 2
I have two main tables(account and product) and a junction table account_product which contains thier association. product is kind of my look up table. one account may have multiple products and a product may be associated with many accounts.

account
----------
acct_num
active
---------

product
---------
prod_id
prod_desc
--------

account_product
------------------
acct_num
prod_id
------------------

Following are my requirements -

1. When I add data, data should be added in account table and account_product table but my product table should be untoched, it should work like a lookup table.
2. When I update data, data should be updated in account table and its association table - account_product. For example if product 2,3 are already assoiated with account and now I want to associate product 5,6 only then association of 2,3 should be deleted from account_product table. product table should be untoched.


I am trying many-to many annotation but everything is getting mess-up.
-> On Add/update, lookup table is being updated.

As I am new to hibernate so struggling alot.

Appriciate any help.


Last edited by sujeetsharma1980 on Sat Oct 01, 2011 10:07 am, edited 2 times in total.

Top
 Profile  
 
 Post subject: Re: Hibernate | Many to many mapping | problem in add and delete
PostPosted: Sat Oct 01, 2011 3:02 am 
Newbie

Joined: Fri Sep 02, 2011 9:28 am
Posts: 4
Try making the class for table product immutable


Top
 Profile  
 
 Post subject: Re: Hibernate | Many to many mapping | problem in add and delete
PostPosted: Sat Oct 01, 2011 10:01 am 
Newbie

Joined: Sat Oct 01, 2011 12:15 am
Posts: 2
nvedia wrote:
Try making the class for table product immutable


Hi,
I have made few changes in my problem statement. Can you please go through it again and suggest? meanwhile I'll try your given suggestion.

Regards,
Sujeet


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.