-->
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.  [ 2 posts ] 
Author Message
 Post subject: JDBCExceptionReporter: Column 'mycol' specified twice
PostPosted: Tue Dec 04, 2007 7:00 pm 
Beginner
Beginner

Joined: Sun Feb 20, 2005 12:14 am
Posts: 49
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
3.2

Mapping documents:

Code:
<class name="SupplierItem" table="supplieritem">
   <id name="id" unsaved-value="null" type="string" length="32" access="field">
      <generator class="uuid"/>
   </id>
   <version name="version" type="long" unsaved-value="null"/>
   
   <property name="manufacturerPartNumber" type="string" access="field"/>
   
   <map name="descriptions" access="field" lazy="true" cascade="all,delete-orphan">
      <key column="supplieritemId" foreign-key="none" not-null="true"/>
      <map-key formula="type" type="string"/>
      <one-to-many class="SupplierItemDescription"/>
   </map>
</class>

Code:
   <class name="SupplierItemDescription" table="supplieritemdescription">
      <id name="id" unsaved-value="null" type="string" length="32" access="field">
           <generator class="uuid"/>
      </id>

      <version name="version" type="long" unsaved-value="null"/>

      <many-to-one name="item" column="supplierItemId" class="SupplierItem" not-null="true" access="field"/>

      <property name="type" type="string" not-null="true" access="field">
         <column name="type" index="type_index"/>
      </property>
      <property name="text" type="string" length="65536" access="field"/>

   </class>


Full stack trace of any exception that occurs:
Code:
1204 DEBUG org.hibernate.SQL log [401] - insert into supplieritem (version, manufacturerPartNumber, supplierPartNumber, supplierImportNumber, uncorrectedWeight, uncorrectedCost, active, discontinued, correctedWeight, correctedCost, qtyAvailable, qtyBackordered, qtyOnOrder, correctedDeliveryLeadTime, uncorrectedDeliveryLeadTime, correctedBackOrderedDate, uncorrectedBackOrderedDate, creation, skuId, supplierId, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
1208 DEBUG org.hibernate.SQL log [401] - insert into supplieritemdescription (version, supplierItemId, type, text, supplieritemId, id) values (?, ?, ?, ?, ?, ?)
1229 DEBUG org.hibernate.SQL log [401] - insert into supplieritemdescription (version, supplierItemId, type, text, supplieritemId, id) values (?, ?, ?, ?, ?, ?)
1237 WARN  org.hibernate.util.JDBCExceptionReporter logExceptions [77] - SQL Error: 1110, SQLState: 42000
1237 ERROR org.hibernate.util.JDBCExceptionReporter logExceptions [78] - Column 'supplierItemId' specified twice
org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
        at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
        at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
        at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:237)
        at org.hibernate.engine.ActionQueue.executeInserts(ActionQueue.java:132)
        at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:245)
        at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181)
        at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107)
        at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187)
        at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
        at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172)
        at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
        at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
        at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535)
        at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523)
        at org.hibernate.impl.SessionImpl.save(SessionImpl.java:519)


Name and version of the database you are using:
mysql 5.0.27

Does anyone have an idea why hibernate is trying to insert supplierId twice in the insert statement?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 04, 2007 7:12 pm 
Beginner
Beginner

Joined: Sun Feb 20, 2005 12:14 am
Posts: 49
adding insert="false" to <many-to-one> takes care of the problem. I do not know if this is the correct way though

Code:
      <many-to-one name="item" column="supplierItemId" class="SupplierItem" not-null="true" access="field" insert="false"/>


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