Hi Everybody, I have a table 'formsprod_items' which has composite primary key as 'itemId' and 'version'. There is another table 'formsprod_grcatCanOrder' which has composite key of 'groupId', 'itemId' and 'version'. The 'itemId' and 'version' fields from formsprod_items table have 1 to many relationship with formsprod_grcatCanOrder table with the 'groupId' field. Eg. 1 itemId and version can have many groupIds. Following are my hibernate mapping files: --Items.hbm.xml-- <class name="Items" table="formsprod_items"> <composite-id> <key-property name="itemId"/> <key-property name="itemVersion" column="version"/> </composite-id> <set name="grpCatCanOrder" table="formsprod_grcatCanOrder" cascade="all" inverse="false" lazy="true" > <key> <column name="itemId" not-null="true"/> <column name="version" not-null="true"/> </key> <one-to-many class="GroupCategoryCanOrder"/> </set> </class>
-- GroupOrder.hbm.xml -- <class name="GroupCategoryCanOrder" table="formsprod_grcatCanOrder" > <composite-id> <key-many-to-one name="item" class="Items" > <column name="itemId" /> <column name="version" /> </key-many-to-one> <key-property name="groupCategoryId" /> </composite-id> </class>
The error which I am getting is "No value specified for mandatory column 'itemid'.". I am explicitly setting the value in my JUnit test class. No records are inserted in the two tables. What am I missing in the mapping file?
|