I got the following exception in my Hibernate mapping file, however, the attributes insert and update are not valid for <one-to-many> tag. Not sure how I can fix the problem. I am using hibernate-mapping-3.0.dtd and Hibernate 3.2.4. Please help.
Code:
Caused by: org.hibernate.MappingException: Repeated column in mapping for entity: test.model.data.SolutionStaffing column: SOLUTION_ID (should be mapped with insert="false" update="false")
Sample table structure:
Code:
CREATE TABLE TEMP.SOLUTION_STAFFING (
SOLUTION_ID BIGINT NOT NULL,
JR_SS_ID INTEGER NOT NULL,
RATIO DOUBLE,
PRIMARY KEY (SOLUTION_ID, JR_SS_ID)
);
CREATE TABLE TEMP.ITEM_MONTHLY_REPORT (
ITEM_ID BIGINT NOT NULL,
YEAR SMALLINT NOT NULL,
MTH SMALLINT NOT NULL,
ITEM_SOL_ID BIGINT,
PRIMARY KEY(ITEM_ID, YEAR, MTH)
);
Mapping file for table ITEM_MONTHLY_REPORT:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="test.model.data.ItemMonthlyReport" table="ITEM_MONTHLY_REPORT" mutable="false" dynamic-insert="false" dynamic-update="false" schema="TEMP">
<!-- common starts -->
<composite-id name="id" class="test.model.data.ItemMthId">
<key-property name="itemId" type="long">
<column name="ITEM_ID" />
</key-property>
<key-property name="mth" type="int">
<column name="MTH" />
</key-property>
<key-property name="year" type="int">
<column name="YEAR" />
</key-property>
</composite-id>
<property name="itemSolutionId" type="java.lang.Long">
<column name="ITEM_SOL_ID" />
</property>
<set name="solutionStaffingSet" lazy="true" >
<key column="SOLUTION_ID" not-null="true" property-ref="itemSolutionId"/>
<one-to-many class="test.model.data.SolutionStaffing" />
</set>
</class>
</hibernate-mapping>
Mapping file for table SOLUTION_STAFFING.
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="test.model.data.SolutionStaffing" table="SOLUTION_STAFFING" schema="TEMP">
<composite-id name="id" class="test.model.data.SolutionStaffingId" >
<key-property name="solutionId" type="long" >
<column name="SOLUTION_ID" />
</key-property>
<key-property name="jrSsId" type="int">
<column name="JR_SS_ID" />
</key-property>
</composite-id>
<property name="ratio" type="java.lang.Double">
<column name="RATIO" precision="53" scale="0" />
</property>
</class>
</hibernate-mapping>