-->
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: many-to-many not updating the mapping table
PostPosted: Sun Jun 07, 2009 12:19 am 
Newbie

Joined: Sat May 23, 2009 2:47 pm
Posts: 3
Hi,

I have a many-to-many that is not working properly, the mapping table is not being updated

I have three tables
Locations
LocationCourseTypes (mapping table)
CourseTypes

and two persistent classes (2 java and 2 hbm.xml files)
Locations
CourseTypes

When I execute the following code, the CourseType and Locations table are updated with 1 row each but the LocationsCourseTypes (mapping table) is not updated:
Locations loc = new Locations();
loc.setLocationId("test1");
loc.setLocationName("test");
loc.setCourseLocId("test");
CourseTypes ct1 = new CourseTypes();
ct1.setCourseTypeId("testCT1");
ct1.setCourseDescription("testDesc1");
loc.getCourseTypes().add(ct1);



Here are my mapping files:
<?xml version="1.0"?>
<hibernate-mapping>
<class name="persistence.entity.CourseTypes" table="CourseTypes" schema="dbo" catalog="RWUSCANIODEV">
<id name="courseTypeId" type="string">
<column name="CourseTypeId" length="10" />
<generator class="assigned" />
</id>
<set name="locationCourseTypeses" inverse="true">
<key>
<column name="CourseTypeID" length="10" not-null="true" />
</key>
<one-to-many class="persistence.entity.LocationCourseTypes" />
</set>
</class>
</hibernate-mapping>

<?xml version="1.0"?>
<hibernate-mapping>
<class name="persistence.entity.Locations" table="Locations" schema="dbo" catalog="RWUSCANIODEV">
<id name="locationId" type="string">
<column name="LocationId" length="5" />
<generator class="assigned" />
</id>
<property name="locationName" type="string">
<column name="LocationName" length="64" not-null="true" />
</property>
<set name="locationCourseTypeses" inverse="true">
<key>
<column name="LocationID" length="5" not-null="true" />
</key>
<one-to-many class="persistence.entity.LocationCourseTypes" />
</set>
</class>
</hibernate-mapping>


Any help would be much appreciated.
Kedaar


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.