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: Repeated column in mapping for entity: with key-many-to-one
PostPosted: Thu May 26, 2005 11:29 am 
Regular
Regular

Joined: Thu Sep 23, 2004 11:53 am
Posts: 83
I noticed this problem has been posted before, but the <key-many-to-one> does not have 'insert' and 'update' attribute so I can set them to false. Is there a different way to appraoch this error when using <key-many-to-one>? As you can see below PROJECT_ID is used twice in wto different foreign key constraints.

Thanks in advance for any help


Hibernate version:
3.0
Mapping documents:

Code:
<class name="com.ProjectStepXref" table="PROJECT_STEP_XREF"
      schema="PPDM37">
      <composite-id name="id" class="com.ProjectStepXrefId">
         <key-many-to-one name="ProjectStep"
            class="com.ProjectStep">
            <column name="PROJECT_ID" length="20" not-null="false" />
            <column name="STEP_ID2" length="20" not-null="false" />
         </key-many-to-one>
         <key-many-to-one name="ProjectStep_1"
            class="com.ProjectStep">
            <column name="PROJECT_ID" length="20" not-null="false" />
            <column name="STEP_ID1" length="20" not-null="false" />
         </key-many-to-one>
         <key-property name="XrefObsNo"
            type="java.math.BigDecimal">
            <column name="XREF_OBS_NO" length="8" not-null="true"
               sql-type="NUMBER" />
         </key-property>
      </composite-id>


Code between sessionFactory.openSession() and session.close():
NA
Full stack trace of any exception that occurs:
09:56:28,000 INFO HbmBinder:1974 - Mapping collection: com.RTvdMethod.SetOfStratWellSection -> STRAT_WELL_SECTION
09:56:28,000 INFO HbmBinder:1974 - Mapping collection: com.RTvdMethod.SetOfStratFieldSection -> STRAT_FIELD_SECTION
09:56:28,000 INFO Configuration:865 - processing association property references
09:56:28,000 INFO Configuration:894 - processing foreign key constraints
%%%% Error Creating SessionFactory %%%%
org.hibernate.MappingException: Repeated column in mapping for entity: com.ProjectStepXref column: PROJECT_ID (should be mapped with insert="false" update="false")
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:504)
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:542)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:335)
at org.hibernate.mapping.RootClass.validate(RootClass.java:188)
at org.hibernate.cfg.Configuration.validate(Configuration.java:816)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1050)
at com.HibernateSessionFactory.currentSession(HibernateSessionFactory.java:49)
at driver.Driver.main(Driver.java:24)
java.lang.NullPointerException
at com.HibernateSessionFactory.currentSession(HibernateSessionFactory.java:56)
at driver.Driver.main(Driver.java:24)
Exception in thread "main"


Name and version of the database you are using:
Oracle 10g

The generated SQL (show_sql=true):
NA

Debug level Hibernate log excerpt:
NA


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 26, 2005 11:45 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
I advise against use of <key-many-to-one>, especially in this case. Replace with a <key-property>, and also a <many-to-one insert=false update=false>.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 26, 2005 5:49 pm 
Regular
Regular

Joined: Thu Sep 23, 2004 11:53 am
Posts: 83
Would this be the correct way using <key-property> and <many-to-one>? Just making sure, since other tables are producing the same error, and there are a total of 1300 tables. By the way if you need the Hibernate tools eclipse plugin to process 1200 tables ... system requirements are at least 2GB if Oracle is running on another machine. Ran like a dream! By the way, the <key-many-to-one> is being generated by the plugin. I noticed an open jira issues on this, so maybe in the future I will not have to manually change the <key-many-to-one> to <key-property> <many-to-one>.

Thanks in advance! :)

Code:
      <composite-id name="id" class="com.ProjectStepXrefId">
         <key-property name="ProjectStep"/>
         <key-property name="ProjectStep_1"/>
         <key-property name="XrefObsNo"
            type="java.math.BigDecimal">
            <column name="XREF_OBS_NO" length="8" not-null="true"
               sql-type="NUMBER" />
         </key-property>
      </composite-id>

      <many-to-one name="ProjectStep" class="com.ProjectStep"
         insert="false" update="false">
         <column name="PROJECT_ID" length="20" not-null="false" />
         <column name="STEP_ID2" length="20" not-null="false" />
      </many-to-one>
      
      <many-to-one name="ProjectStep_1" class="com.ProjectStep"
         insert="false" update="false">
         <column name="PROJECT_ID" length="20" not-null="false" />
         <column name="STEP_ID1" length="20" not-null="false" />
      </many-to-one>


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.