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.  [ 1 post ] 
Author Message
 Post subject: persisting changes in uni-directional many-to-many relation
PostPosted: Wed Jul 02, 2008 9:28 am 
Newbie

Joined: Tue Mar 11, 2008 4:11 am
Posts: 3
I have uni directional many-to-many relation; Person *... * Address. i have a joined table PersonAddress which holds just the id of Person and Address. Relation is uni-directional; from Person to Address only. When i add address to Person or remove address to Person, it's not persisted. I have my mapping file below:

Person mapping file
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
  <class name="Domain.Person, Domain" table="Person" lazy="false">
    <id name="ID" column="ID" unsaved-value="0">
      <generator class="identity" />
    </id>
    <property name="Name" column="Name"/>   
    <bag name="Addresses" lazy="false"  table="PersonAddress" cascade="all">
      <key column="PersonId"/>
      <many-to-many column="AddressId" class="Domain.Address, Domain"/>
    </bag>
  </class>
</hibernate-mapping>


Address mapping file
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
  <class name="Domain.Address, Domain" table="Address" lazy="false">
    <id name="ID" column="ID" unsaved-value="0">
      <generator class="identity" />
    </id>
    <property name="Name" column="Name"/>   
  </class>
</hibernate-mapping>


i tried googling and found this http://technicalmumbojumbo.wordpress.com/2007/09/25/investigating-hibernate-associations-many-to-many/ but it's in java. i tried it as well but it's not working; i can't persist addition and deletion of address of person from person class. any thoughts?


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

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.