-->
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 doesn't save in cascade!!??
PostPosted: Fri Jan 16, 2009 6:41 am 
Regular
Regular

Joined: Mon Oct 02, 2006 12:03 pm
Posts: 62
Hello forum, I have a Customer <--> Agent M:N relation. I have mapped these classes as:

Mapping:
Agent.customers

Code:
<bag name="customers" table="CUSTOMER_has_AGENT" cascade="all">
         <key column="AGENT_ID"/>
         <many-to-many column="CUSTOMER_ID" class="com.gmsoft.model.entities.Customer"/>
      </bag>


Customer.agents
Code:
<bag name="agents" table="CUSTOMER_has_AGENT" cascade="all">
         <key column="CUSTOMER_ID"/>
         <many-to-many column="AGENT_ID" class="com.gmsoft.model.entities.Agent"/>
      </bag>



The problem is that I create a new Customer, and add an existing agent into your agents collection. I save the customer, however only insert the new client into CUSTOMER TABLE, and doesn't insert the relation into CUSTOMER_has_AGENT TABLE. Can you help me please?

Thanks for all.
I will appreciate your help a lot.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2009 6:54 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
Try and mark one end as inverse="true"

_________________
--Wolfgang


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.