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.