-->
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.  [ 6 posts ] 
Author Message
 Post subject: many-to-one on same column in subclass
PostPosted: Wed Jul 28, 2004 1:01 pm 
Beginner
Beginner

Joined: Fri Mar 05, 2004 6:33 pm
Posts: 29
Location: Vancouver, BC, Canada
A, B, C, D are classes

B extends A

the A,B hierarchy is mapped on the same table T

I have two many-to-one relations on the same column of T in the classes from A and B as below.

A M------to----- 1 C
B M------to------1 D

Hibernate is complaining about a double mapping. Is there any way of modelling these relations?

Thank you!

Calin


Top
 Profile  
 
 Post subject: Any type mapping/ maybe more details in the book?
PostPosted: Thu Jul 29, 2004 3:49 pm 
Beginner
Beginner

Joined: Fri Mar 05, 2004 6:33 pm
Posts: 29
Location: Vancouver, BC, Canada
Should I use an ANY type mapping o solve this? Would I find an answer if I bought the book?

I don't see why it won't work out of the box. I am using a table-per-class-hierarchy model and according to the table 8.1 at the end of http://www.hibernate.org/hib_docs/refer ... tance.html polymorphic many-to-one should work.

What am I missing? is it not polymorphic many-to-one what I do here?

Thanks!

Calin


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 29, 2004 3:50 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Have you read the red box before posting?

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 29, 2004 3:51 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Please read the instructions for using the user forum,


Top
 Profile  
 
 Post subject: Details + I'm sorry
PostPosted: Thu Jul 29, 2004 4:25 pm 
Beginner
Beginner

Joined: Fri Mar 05, 2004 6:33 pm
Posts: 29
Location: Vancouver, BC, Canada
Sorry for not following the guidelines. It was because I did not know if I am allowed to post the file below in a public forum but I checked and it's OK. Sorry again.

If I map it with insert=false, update=false like the exception says, everything works, but I want it to be read/write.

I use hibernate 2.1.4, + Oracle 9i
I Get this exception when hibernate starts up:

net.sf.hibernate.MappingException: Repeated column in mapping for class com.teammeta.test.ProcessDataMessageContentOccurrence should be mapped with insert="false" update="false": SYSPRO_ID
at net.sf.hibernate.persister.AbstractEntityPersister.checkColumnDuplication(AbstractEntityPersister.java:1002)
at net.sf.hibernate.persister.EntityPersister.<init>(EntityPersister.java:821)
at net.sf.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:42)
at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:137)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:768)
at com.teammeta.test.HibernateTestHarness.currentSession(HibernateTestHarness.java:107)
at com.teammeta.test.HibernateTestHarness.main(HibernateTestHarness.java:60)




mapping doc follows

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<!-- reldfId = 6131 -->

<hibernate-mapping>
<class
name="com.teammeta.test.SystemProcessOccurrence"
table="SYSTEM_PROCESS_OCCURRENCE"
discriminator-value="68"
>

<meta attribute="class-description">
reldfId = 6131
tydfId= 68
table= SYSTEM_PROCESS_OCCURRENCE
</meta>
<id
name="sysprooccId"
type="big_decimal"
column="SYSPROOCC_ID"
>
<generator class="sequence">
<param name="sequence">ID_SEQ</param>
</generator>
</id>
<discriminator column="TYDF_ID" not-null="true"/>
<!-- START Associations -->

<many-to-one
name="systemProcess"
class="com.teammeta.test.SystemProcess"
column="SYSPRO_ID"
>
<meta attribute="field-description">
SYSTEM PROCESS.
ASSOCID=296516
DESTINATION TYPE: SYSTEM PROCESS tydf_id=69
THIS TYPE: SYSTEM PROCESS OCCURRENCE
@return com.teammeta.test.SystemProcess object
</meta>
</many-to-one>
<set name="systemProcessOccurrenceSet"
inverse="true"
lazy="true"
where="TYDF_ID=68"
>
<meta attribute="field-description">
SYSTEM PROCESS OCCURRENCE.
@return Set of com.teammeta.test.SystemProcessOccurrence objects
</meta>
<key column="SYSPROOCC_ID_PARENT"/>
<one-to-many class="com.teammeta.test.SystemProcessOccurrence"/>
</set>
<many-to-one
name="systemProcessOccurrenceChildOf"
class="com.teammeta.test.SystemProcessOccurrence"
column="SYSPROOCC_ID_PARENT"
>
<meta attribute="field-description">
SYSTEM PROCESS OCCURRENCE CHILD OF.
ASSOCID=297410
DESTINATION TYPE: SYSTEM PROCESS OCCURRENCE tydf_id=68
THIS TYPE: SYSTEM PROCESS OCCURRENCE
@return com.teammeta.test.SystemProcessOccurrence object
</meta>
</many-to-one>
<set name="synchronizationLogSet"
inverse="true"
lazy="true"
where="TYDF_ID=682"
>
<meta attribute="field-description">
SYNCHRONIZATION LOG.
@return Set of com.teammeta.test.SynchronizationLog objects
</meta>
<key column="SYSPROOCC_ID"/>
<one-to-many class="com.teammeta.test.SynchronizationLog"/>
</set>
<set name="synchronizationOccurrenceResultSet"
inverse="true"
lazy="true"
where="TYDF_ID=580"
>
<meta attribute="field-description">
SYNCHRONIZATION OCCURRENCE RESULT.
@return Set of com.teammeta.test.SynchronizationOccurrenceResult objects
</meta>
<key column="SYSPROOCC_ID"/>
<one-to-many class="com.teammeta.test.SynchronizationOccurrenceResult"/>
</set>
<set name="systemProcessParameterValueSet"
inverse="true"
lazy="true"
where="TYDF_ID=567071"
>
<meta attribute="field-description">
SYSTEM PROCESS PARAMETER VALUE.
@return Set of com.teammeta.test.SystemProcessParameterValue objects
</meta>
<key column="SYSPROOCC_ID"/>
<one-to-many class="com.teammeta.test.SystemProcessParameterValue"/>
</set>
<!-- END Associations -->
<!-- START PROPERTIES -->
<!--
colref ID = 626270 impo_id = 592747
coldf ID = 592747 impo_id = 592747
-->
<property
name="notes"
type="string"
column="NOTES"
length="4000"
not-null= "false"/>
<!--
colref ID = 626271 impo_id = 592744
coldf ID = 592744 impo_id = 592744
-->
<property
name="externalJobId"
type="string"
column="EXTERNAL_JOB_ID"
length="40"
not-null= "false"/>

<!--
colref ID = 567440 impo_id = 134452
coldf ID = 134452 impo_id = 134452
-->
<property
name="completionStatus"
type="string"
column="COMPLETION_STATUS"
length="30"
not-null= "true"/>
<!--
colref ID = 567441 impo_id = 124608
coldf ID = 124608 impo_id = 124608
-->
<property
name="startDateTime"
type="date"
column="START_DATE_TIME"
not-null= "true"/>
<!--
colref ID = 567442 impo_id = 124610
coldf ID = 124610 impo_id = 124610
-->
<property
name="endDateTime"
type="date"
column="END_DATE_TIME"
not-null= "false"/>
<!--
colref ID = 567443 impo_id = 298814
coldf ID = 298814 impo_id = 298814
-->
<property
name="description"
type="string"
column="DESCRIPTION"
length="240"
not-null= "false"/>
<!--
colref ID = 567445 impo_id = 124604
coldf ID = 124604 impo_id = 124604
-->
<property
name="successfulRecordsCount"
type="java.lang.Long"
column="SUCCESSFUL_RECORDS_COUNT"
length="10"
not-null= "false"/>
<!--
colref ID = 567446 impo_id = 124606
coldf ID = 124606 impo_id = 124606
-->
<property
name="errorRecordsCount"
type="java.lang.Long"
column="ERROR_RECORDS_COUNT"
length="10"
not-null= "false"/>
<!--
colref ID = 567447 impo_id = 124626
coldf ID = 124626 impo_id = 124626
-->
<property
name="lastProcessedReferenceId"
type="string"
column="LAST_PROCESSED_REFERENCE_ID"
length="40"
not-null= "false"/>

<!--
colref ID = 567449 impo_id = 124614
coldf ID = 124614 impo_id = 124614
-->
<property
name="createDateTime"
type="date"
column="CREATE_DATE_TIME"
not-null= "true"/>
<!--
colref ID = 567450 impo_id = 124598
coldf ID = 124598 impo_id = 124598
-->
<property
name="createUser"
type="string"
column="CREATE_USER"
length="30"
not-null= "true"/>
<!--
colref ID = 567451 impo_id = 124620
coldf ID = 124620 impo_id = 124620
-->
<property
name="createPtyId"
type="big_decimal"
column="CREATE_PTY_ID"
length="38"
not-null= "false"/>
<!--
colref ID = 567452 impo_id = 124600
coldf ID = 124600 impo_id = 124600
-->
<property
name="updateUser"
type="string"
column="UPDATE_USER"
length="30"
not-null= "false"/>
<!--
colref ID = 567453 impo_id = 124612
coldf ID = 124612 impo_id = 124612
-->
<property
name="updateDateTime"
type="date"
column="UPDATE_DATE_TIME"
not-null= "false"/>
<!--
colref ID = 567454 impo_id = 124622
coldf ID = 124622 impo_id = 124622
-->
<property
name="updatePtyId"
type="big_decimal"
column="UPDATE_PTY_ID"
length="38"
not-null= "false"/>
<!--
colref ID = 1171713 impo_id = 1171649
coldf ID = 1171649 impo_id = 1171649
-->
<property
name="commitPeriod"
type="java.lang.Long"
column="COMMIT_PERIOD"
length="10"
not-null= "false"/>
<!--
colref ID = 1171714 impo_id = 1171648
coldf ID = 1171648 impo_id = 1171648
-->
<property
name="sampleCount"
type="java.lang.Long"
column="SAMPLE_COUNT"
length="10"
not-null= "false"/>
<!--
colref ID = 1171715 impo_id = 1171647
coldf ID = 1171647 impo_id = 1171647
-->
<property
name="maxErrorCount"
type="java.lang.Long"
column="MAX_ERROR_COUNT"
length="10"
not-null= "false"/>
<!--
colref ID = 1171716 impo_id = 1171651
coldf ID = 1171651 impo_id = 1171651
-->
<property
name="maxDuration"
type="byte"
column="MAX_DURATION"
not-null= "false"/>
<!-- END PROPERTIES -->
</class>

<subclass
name="com.teammeta.test.ProcessDataMessageOccurrence"
extends="com.teammeta.test.SystemProcessOccurrence"
discriminator-value="413987">
<meta attribute="class-description">
reldfId = 6131
tydfId= 413987
table= SYSTEM_PROCESS_OCCURRENCE
</meta>

<many-to-one
name="dataMessage"
class="com.teammeta.test.DataMessage"
column="OBJ_ID"
>
<meta attribute="field-description">
DATA MESSAGE.
ASSOCID=417480
DESTINATION TYPE: DATA MESSAGE tydf_id=116
THIS TYPE: PROCESS DATA MESSAGE OCCURRENCE
@return com.teammeta.test.DataMessage object
</meta>
</many-to-one>
<set name="processDataMessageContentOccurrenceSet"
inverse="true"
lazy="true"
where="TYDF_ID=413992"
>
<meta attribute="field-description">
PROCESS DATA MESSAGE CONTENT OCCURRENCE.

@return Set of com.teammeta.test.ProcessDataMessageContentOccurrence objects
</meta>
<key column="SYSPROOCC_ID_PARENT"/>
<one-to-many class="com.teammeta.test.ProcessDataMessageContentOccurrence"/>
</set>
<many-to-one
name="processDataMessageOrContent"
class="com.teammeta.test.ProcessDataMessageOrContent"
column="SYSPRO_ID"
>
<meta attribute="field-description">
PROCESS DATA MESSAGE OR CONTENT.
ASSOCID=417453
DESTINATION TYPE: PROCESS DATA MESSAGE OR CONTENT tydf_id=260876
THIS TYPE: PROCESS DATA MESSAGE OCCURRENCE
@return com.teammeta.test.ProcessDataMessageOrContent object
</meta>
</many-to-one>
<set name="synchronizationOccurrenceSet"
inverse="true"
lazy="true"
where="TYDF_ID=413947"
>
<meta attribute="field-description">
SYNCHRONIZATION OCCURRENCE.

@return Set of com.teammeta.test.SynchronizationOccurrence objects
</meta>
<key column="SYSPROOCC_ID"/>
<one-to-many class="com.teammeta.test.SynchronizationOccurrence"/>
</set>
<set name="processDataMessageParameterValueSet"
inverse="true"
lazy="true"
where="TYDF_ID=1586460"
>
<meta attribute="field-description">
PROCESS DATA MESSAGE PARAMETER VALUE.

@return Set of com.teammeta.test.ProcessDataMessageParameterValue objects
</meta>
<key column="SYSPROOCC_ID"/>
<one-to-many class="com.teammeta.test.ProcessDataMessageParameterValue"/>
</set>
<!-- END Associations -->
<!-- START properties -->

<property
name="tydfIdDatamsgcnt"
type="big_decimal"
column="TYDF_ID_DATAMSGCNT"
length="38"
not-null= "false"/>
<property
name="endingStatusDatamsgcnt"
type="string"
column="ENDING_STATUS_DATAMSGCNT"
length="30"
not-null= "false"/>
<property
name="smmapIdProcessLast"
type="big_decimal"
column="SMMAP_ID_PROCESS_LAST"
length="38"
not-null= "false"/>
<!-- END PROPERTIES -->
</subclass>
<subclass
name="com.teammeta.test.ProcessDataMessageContentOccurrence"
extends="com.teammeta.test.SystemProcessOccurrence"
discriminator-value="413992">
<meta attribute="class-description">
reldfId = 6131
tydfId= 413992
table= SYSTEM_PROCESS_OCCURRENCE
</meta>

<many-to-one
name="dataMessageContentDefinition"
class="com.teammeta.test.DataMessageContentMapping"
column="OBJ_ID"
>
<meta attribute="field-description">
DATA MESSAGE CONTENT DEFINITION.
ASSOCID=417487
DESTINATION TYPE: DATA MESSAGE CONTENT MAPPING tydf_id=416
THIS TYPE: PROCESS DATA MESSAGE CONTENT OCCURRENCE
@return com.teammeta.test.DataMessageContentMapping object
</meta>
</many-to-one>
<set name="synchronizationPassOccurrenceSet"
inverse="true"
lazy="true"
where="TYDF_ID=413997"
>
<meta attribute="field-description">
SYNCHRONIZATION PASS OCCURRENCE.

@return Set of com.teammeta.test.SystemMessageMappingOccurrence objects
</meta>
<key column="SYSPROOCC_ID_PARENT"/>
<one-to-many class="com.teammeta.test.SystemMessageMappingOccurrence"/>
</set>
<many-to-one
name="processDataMessageOccurrence"
class="com.teammeta.test.ProcessDataMessageOccurrence"
column="SYSPROOCC_ID_PARENT"
>
<meta attribute="field-description">
PROCESS DATA MESSAGE OCCURRENCE.
ASSOCID=417437
DESTINATION TYPE: PROCESS DATA MESSAGE OCCURRENCE tydf_id=413987
THIS TYPE: PROCESS DATA MESSAGE CONTENT OCCURRENCE
@return com.teammeta.test.ProcessDataMessageOccurrence object
</meta>
</many-to-one>
<many-to-one
name="processDataMessageOrContent"
class="com.teammeta.test.ProcessDataMessageOrContent"
column="SYSPRO_ID"
>
<meta attribute="field-description">
PROCESS DATA MESSAGE OR CONTENT.
ASSOCID=417461
DESTINATION TYPE: PROCESS DATA MESSAGE OR CONTENT tydf_id=260876
THIS TYPE: PROCESS DATA MESSAGE CONTENT OCCURRENCE
@return com.teammeta.test.ProcessDataMessageOrContent object
</meta>
</many-to-one>
<!-- END Associations -->
<!-- START properties -->

<!-- END PROPERTIES -->
</subclass>
<subclass
name="com.teammeta.test.SystemMessageMappingOccurrence"
extends="com.teammeta.test.SystemProcessOccurrence"
discriminator-value="413997">
<meta attribute="class-description">
reldfId = 6131
tydfId= 413997
table= SYSTEM_PROCESS_OCCURRENCE
</meta>

<set name="synchronizationStepOccurrenceSet"
inverse="true"
lazy="true"
where="TYDF_ID=413957"
>
<meta attribute="field-description">
SYNCHRONIZATION STEP OCCURRENCE.

@return Set of com.teammeta.test.SynchronizationStepOccurrence objects
</meta>
<key column="SYSPROOCC_ID"/>
<one-to-many class="com.teammeta.test.SynchronizationStepOccurrence"/>
</set>
<many-to-one
name="processDataMessageContentOccurrence"
class="com.teammeta.test.ProcessDataMessageContentOccurrence"
column="SYSPROOCC_ID_PARENT"
>
<meta attribute="field-description">
PROCESS DATA MESSAGE CONTENT OCCURRENCE.
ASSOCID=417445
DESTINATION TYPE: PROCESS DATA MESSAGE CONTENT OCCURRENCE tydf_id=413992
THIS TYPE: SYSTEM MESSAGE MAPPING OCCURRENCE
@return com.teammeta.test.ProcessDataMessageContentOccurrence object
</meta>
</many-to-one>
<!-- END Associations -->
<!-- START properties -->

<!-- END PROPERTIES -->
</subclass>
<subclass
name="com.teammeta.test.SystemProcessOccurenceOther"
extends="com.teammeta.test.SystemProcessOccurrence"
discriminator-value="580345">
<meta attribute="class-description">
reldfId = 6131
tydfId= 580345
table= SYSTEM_PROCESS_OCCURRENCE
</meta>

<!-- END Associations -->
<!-- START properties -->
<!-- END PROPERTIES -->
</subclass>
<subclass
name="com.teammeta.test.SnapshotOccurrence"
extends="com.teammeta.test.SystemProcessOccurrence"
discriminator-value="1510657">
<meta attribute="class-description">
reldfId = 6131
tydfId= 1510657
table= SYSTEM_PROCESS_OCCURRENCE
</meta>

<set name="snapshotParameterValueSet"
inverse="true"
lazy="true"
where="TYDF_ID=1510637"
>
<meta attribute="field-description">
SNAPSHOT PARAMETER VALUE.

@return Set of com.teammeta.test.SnapshotParameterValue objects
</meta>
<key column="SYSPROOCC_ID"/>
<one-to-many class="com.teammeta.test.SnapshotParameterValue"/>
</set>
<many-to-one
name="snapshotSystemProcess"
class="com.teammeta.test.SnapshotSystemProcess"
column="SYSPRO_ID"
>
<meta attribute="field-description">
SNAPSHOT SYSTEM PROCESS.
ASSOCID=1511105
DESTINATION TYPE: SNAPSHOT SYSTEM PROCESS tydf_id=1510662
THIS TYPE: SNAPSHOT OCCURRENCE
@return com.teammeta.test.SnapshotSystemProcess object
</meta>
</many-to-one>
<!-- END Associations -->
<!-- START properties -->
<!-- END PROPERTIES -->
</subclass>
<subclass
name="com.teammeta.test.MetaDataMigration"
extends="com.teammeta.test.SystemProcessOccurrence"
discriminator-value="1743139">
<meta attribute="class-description">
reldfId = 6131
tydfId= 1743139
table= SYSTEM_PROCESS_OCCURRENCE
</meta>

<!-- END Associations -->
<!-- START properties -->
<!-- END PROPERTIES -->
</subclass>
<subclass
name="com.teammeta.test.OperationRunOccurrence"
extends="com.teammeta.test.SystemProcessOccurrence"
discriminator-value="2156099">
<meta attribute="class-description">
reldfId = 6131
tydfId= 2156099
table= SYSTEM_PROCESS_OCCURRENCE
</meta>


<set name="operationRunParameterValueSet"
inverse="true"
lazy="true"
where="TYDF_ID=2156119"
>
<meta attribute="field-description">
OPERATION RUN PARAMETER VALUE.

@return Set of com.teammeta.test.OperationRunParameterValue objects
</meta>
<key column="SYSPROOCC_ID"/>
<one-to-many class="com.teammeta.test.OperationRunParameterValue"/>
</set>
<!-- END Associations -->
<!-- START properties -->
<!-- END PROPERTIES -->
</subclass>
<subclass
name="com.teammeta.test.AggregateRefresh"
extends="com.teammeta.test.SystemProcessOccurrence"
discriminator-value="1928078">
<meta attribute="class-description">
reldfId = 6131
tydfId= 1928078
table= SYSTEM_PROCESS_OCCURRENCE
</meta>

<!-- END Associations -->
<!-- START properties -->
<!-- END PROPERTIES -->
</subclass>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 03, 2004 2:33 am 
Beginner
Beginner

Joined: Fri Mar 05, 2004 6:33 pm
Posts: 29
Location: Vancouver, BC, Canada
Hello,

I got the book, I saw what you mean by polymorphic associations.

I was wondering, what would be the best way to implement the kind of associations that I have in my mapping file? I'd really appreciate your oppinion.

Thanks.

Calin


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.