-->
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.  [ 3 posts ] 
Author Message
 Post subject: MappingException: Repeated column in mapping for class ...
PostPosted: Tue Sep 09, 2003 9:42 am 
Newbie

Joined: Wed Aug 27, 2003 2:53 pm
Posts: 14
Location: New Jersey
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


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 09, 2003 10:09 am 
Newbie

Joined: Wed Aug 27, 2003 2:53 pm
Posts: 14
Location: New Jersey
As a follow-up to this issue, I also have the situation where the offensive columns are both a subset of a key-many-to-one component and a subset of a many-to-one component. In this case, how am I supposed to set the
Quote:
insert="false" update="false"

properties for only a subset of the columns?

Thanks,
Sarah


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 06, 2004 11:15 am 
Newbie

Joined: Tue Sep 02, 2003 10:35 pm
Posts: 9
I also have a simiilar problem with the following schema mapping because the country code and national number are declared twice.

<class name="VxsUserRegisteredPhone" table="vxs_user_registered_phone" discriminator-value="null">
<composite-id class="VxsUserRegisteredPhone$Key">
<key-property name="domainId" column="DOMAIN_ID" />
<key-property name="countryCode" column="COUNTRY_CODE"/>
<key-property name="nationalCode" column="NATIONAL_NUMBER"/>
</composite-id>
<many-to-one name="user" class="VxsUser" column="user_id" not-null="true"/>
<component name="phoneNumber" class="com.voxsurf.core.telephony.VxsPhoneNumber">
<property name="countryCode" column="COUNTRY_CODE"/>
<property name="nationalCode" column="NATIONAL_NUMBER" not-null="true"/>
</component>
</class>

What I'd really like is for the composite id to be able to contain a component...
<class name="VxsUserRegisteredPhone" table="vxs_user_registered_phone" discriminator-value="null">
<composite-id class="VxsUserRegisteredPhone$Key">
<key-property name="domainId" column="DOMAIN_ID" />
<component name="phoneNumber" class="com.voxsurf.core.telephony.VxsPhoneNumber">
<property name="countryCode" column="COUNTRY_CODE"/>
<property name="nationalCode" column="NATIONAL_NUMBER" not-null="true"/>
</component>
</composite-id>
<many-to-one name="user" class="VxsUser" column="user_id" not-null="true"/>
</class>

This doesn't look possible from the DTD. Is there another way?

Chris


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

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.