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
|