I've just upgraded from hibernate2.0 to hibernate2.0.3 and I'm getting a mapping exception where I did not before.
Prior to upgrading to hibernate2.0.3, no exception was thrown when parsing the mapping, but hibernate could not properly bind variables to the generated insert statement for the specific class. [I was planning on posting a question about this problem . . . and now I think it will be easier to explain].
The error I get is:
Quote:
MappingException: Repeated column in mapping for class org.ets.k12.generic.domain.PersonTestSection should be mapped with insert="false" update="false": TST_ADM_MO_NO
The mapping that I have is:
Quote:
<class name="org.ets.k12.generic.domain.PersonTestSection" table="PRSN_TST_SCTN">
<composite-id unsaved-value="any">
<key-many-to-one name="testAdminGradeTestSection" class="org.ets.k12.generic.domain.TestAdministrationGradeTestSection">
<column name="TST_ADM_MO_NO"/>
<column name="TST_ADM_YR_NO"/>
<column name="GRD_LVL_TYP_CDE"/>
<column name="TST_SCTN_CDE"/>
</key-many-to-one>
<key-many-to-one name="prsnTestAdmin" class="org.ets.k12.generic.domain.PersonTestAdministration">
<column name="PRSN_ID_NO"/>
<column name="PRSN_RLE_TYP_CDE"/>
<column name="TST_ADM_MO_NO"/>
<column name="TST_ADM_YR_NO"/>
</key-many-to-one>
</composite-id>
<property column="PRSN_TST_SCTN_PRE_ID_FLG" name="preIdFlag" type="yes_no"/>
<property column="PRSN_TST_SCTN_BOOK_SER_NO" name="bookSerNo" type="java.lang.Long"/>
<property column="EDUCL_JRSDTN_CRCLM_SCTN_NO" name="educlJrsDtnNo" type="java.lang.String"/>
<property column="TCHR_PRSN_ID_TXT" name="tchrPrsnIdTxt" type="java.lang.String"/>
<property column="PRSN_TST_ADM_LNKG_NO" name="lnkgNo" type="java.lang.Long"/>
<many-to-one name="langTypeCode" class="org.ets.k12.generic.domain.Language">
<column name="LANG_TYP_CDE"/>
</many-to-one>
<property column="UPDT_DTE_TM" name="lastUpdated" type="java.sql.Timestamp"/>
<property column="UPDT_USR_LGN_CDE" name="lastUpdatedBy" type="java.lang.String"/>
</class>
The problem that I have is that the class PersonTestSection has a composite id with two key-many-to-one components (PersonTestAdministration and TestAdministrationGradeTestSection), each of which includes in its primary key the same key-many-to-one component (TestAdministration). The mapping exception suggests that I change the mapping to add
Quote:
insert="false" update="false"
I cannot do this to key-many-to-one components . . . the DTD does not allow it.
This seems to be a bug in hibernate -- not supporting this type of mapping for primary keys.
Unfortunately, in our application we are required to use complex composite keys (i.e., we don't have control over the schema and have lost the fight for generated primary keys) and we have lots of situations which result in this problem.
Any thoughts?
Thanks,
Sarah