SQL Error: 957, SQLState: 42000 ORA-00957: duplicate column name
1. PositionLinkage config
?<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
??? <class name="com.xxx.fmk.model.PositionLinkage"
??? ?table="POSITIONLINKAGE"
??? ?schema="GCD">
??????? <composite-id>
??????? ?<key-property name="clientPositionID"/>
??????? ?<key-property name="linkedPositionID"/>
??????? </composite-id>
??????? <property name="clientPvtrsID" type="integer">
??????????? <column name="CLIENTPVTRSID" precision="22" scale="0" />
??????? </property>
??????? <property name="clientPositionID" type="integer">
??????????? <column name="CLIENTPOSITIONID" precision="22" scale="0" />
??????? </property>
??????? <property name="linkedPvtrsID" type="integer">
??????????? <column name="LINKEDPVTRSID" precision="22" scale="0" />
??????? </property>
??????? <property name="linkedPositionID" type="integer">
??????????? <column name="LINKEDPOSITIONID" precision="22" scale="0" />
??????? </property>
??????? <property name="linkAmount" type="double">
??????????? <column name="LINKAMOUNT" precision="13" scale="6" />
??????? </property>
??????? <property name="linkageType" type="string">
??????????? <column name="LINKAGETYPE" length="32" />
??????? </property>
??????? <property name="calcType" type="string">
??????????? <column name="CALCTYPE" length="11" />
??????? </property>
??????? <property name="version" type="integer">
??????????? <column name="VERSION" precision="22" scale="0" />
??????? </property>
??????? <property name="createdBy" type="string">
??????????? <column name="CREATEDBY" length="50" />
??????? </property>
??????? <property name="creationTime" type="timestamp">
??????????? <column name="CREATIONDATE"/>
??????? </property>
??????? <property name="modifyBy" type="string">
??????????? <column name="MODIFIEDBY" length="50" />
??????? </property>
??????? <property name="modificationDate" type="timestamp">
??????????? <column name="MODIFICATIONDATE"/>
??????? </property>
??? </class>
</hibernate-mapping>
2. save or select
?select
??????? positionli0_.clientPositionID as clientPo1_40_,
??????? positionli0_.linkedPositionID as linkedPo2_40_,
??????? positionli0_.CLIENTPVTRSID as CLIENTPV3_40_,
??????? positionli0_.CLIENTPOSITIONID as CLIENTPO1_40_,
??????? positionli0_.LINKEDPVTRSID as LINKEDPV4_40_,
??????? positionli0_.LINKEDPOSITIONID as LINKEDPO2_40_,
??????? positionli0_.LINKAMOUNT as LINKAMOUNT40_,
??????? positionli0_.LINKAGETYPE as LINKAGET6_40_,
??????? positionli0_.CALCTYPE as CALCTYPE40_,
??????? positionli0_.VERSION as VERSION40_,
??????? positionli0_.CREATEDBY as CREATEDBY40_,
??????? positionli0_.CREATIONDATE as CREATIO10_40_,
??????? positionli0_.MODIFIEDBY as MODIFIEDBY40_,
??????? positionli0_.MODIFICATIONDATE as MODIFIC12_40_
??? from
??????? GCD.POSITIONLINKAGE positionli0_
??? where
??????? positionli0_.linkedPositionID=?
?insert
??? into
??????? GCD.POSITIONLINKAGE
??????? (CLIENTPVTRSID, CLIENTPOSITIONID, LINKEDPVTRSID, LINKEDPOSITIONID, LINKAMOUNT, LINKAGETYPE, CALCTYPE, VERSION, CREATEDBY, CREATIONDATE, MODIFIEDBY, MODIFICATIONDATE,clientPositionID, linkedPositionID)
??? values
??????? (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
?
3.exception
09/05/2011 01:47:00, 369 [TIBCO EMS Session Dispatcher (23812)] [ WARN] JDBCExceptionReporter :[77] - SQL Error: 957, SQLState: 42000
09/05/2011 01:47:00, 370 [TIBCO EMS Session Dispatcher (23812)] [ERROR] JDBCExceptionReporter :[78] - ORA-00957: duplicate column name
09/05/2011 01:47:00, 371 [TIBCO EMS Session Dispatcher (23812)] [ERROR] AbstractFlushingEventListener :[301] - Could not synchronize database state with session
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:249)
??????? at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:92)
??????? at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:87)
??????? at org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(AbstractBatcher.java:218)
??????? at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2174)
??????? at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2610)
??????? at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:52)
??????? at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
??????? at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
??????? at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
??????? at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
??????? at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
??????? at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
??????? at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
??????? at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
??????? at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:570)
??????? at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:651)
??????? at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:621)
??????? at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:311)
??????? at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:117)
??????? at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:161)
??????? at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
??????? at $Proxy49.processBuyTrade(Unknown Source)
??????? at com.xxx.biz.position.SwapEventHandler.processSwapTrade(SwapEventHandler.java:282)
??????? at com.xxx.biz.position.SwapEventHandler.processSwapTrade(SwapEventHandler.java:255)
??????? at com.xxx.biz.position.SwapEventHandler.processSwapEvent(SwapEventHandler.java:212)
??????? at com.xxx.fmk.gfinet.ems.EventSubscriber.onMessage(EventSubscriber.java:73)
??????? at gfinet.messaging.ems.EMSListener.onMessage(EMSListener.java:98)
??????? at com.tibco.tibjms.TibjmsxSessionImp._submit(TibjmsxSessionImp.java:4088)
??????? at com.tibco.tibjms.TibjmsxSessionImp._dispatchAsyncMessage(TibjmsxSessionImp.java:2216)
??????? at com.tibco.tibjms.TibjmsxSessionImp$Dispatcher.run(TibjmsxSessionImp.java:3612)
Caused by: java.sql.BatchUpdateException: ORA-00957: duplicate column name
??????? at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:343)
??????? at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10698)
??????? at org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:294)
??????? at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
??????? at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:242)
??????? ... 30 more
?
4.solution
change config as below
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
??? <class name="com.xxx.fmk.model.PositionLinkage"
??? ?table="POSITIONLINKAGE"
??? ?schema="GCD">
??????? <composite-id>
??????? ?<key-property name="clientPositionID" column="CLIENTPOSITIONID"/>
??????? ?<key-property name="linkedPositionID" column="LINKEDPOSITIONID"/>
??????? </composite-id>
??????? <property name="clientPvtrsID" type="integer">
??????????? <column name="CLIENTPVTRSID" precision="22" scale="0" />
??????? </property>
??????? <property name="linkedPvtrsID" type="integer">
??????????? <column name="LINKEDPVTRSID" precision="22" scale="0" />
??????? </property>
??????? <property name="linkAmount" type="double">
??????????? <column name="LINKAMOUNT" precision="13" scale="6" />
??????? </property>
??????? <property name="linkageType" type="string">
??????????? <column name="LINKAGETYPE" length="32" />
??????? </property>
??????? <property name="calcType" type="string">
??????????? <column name="CALCTYPE" length="11" />
??????? </property>
??????? <property name="version" type="integer">
??????????? <column name="VERSION" precision="22" scale="0" />
??????? </property>
??????? <property name="createdBy" type="string">
??????????? <column name="CREATEDBY" length="50" />
??????? </property>
??????? <property name="creationTime" type="timestamp">
??????????? <column name="CREATIONDATE"/>
??????? </property>
??????? <property name="modifyBy" type="string">
??????????? <column name="MODIFIEDBY" length="50" />
??????? </property>
??????? <property name="modificationDate" type="timestamp">
??????????? <column name="MODIFICATIONDATE"/>
??????? </property>
??? </class>
</hibernate-mapping>
5.reference
http://www.theserverside.com/discussions/thread.tss?thread_id=14842
Hello,I am calling one create() method in my entity bean. I have correct values for all fields (one int for the primary key and the rest are integer also). When I try to run it I get a strange error which I will paste in at the bottom (duplicate column name).
17:05:44,030 ERROR [OsdProofsWeekReplace] Could not create entity
java.sql.SQLException: ORA-00957: duplicate column name
????????at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
????????at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
????????at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543)
????????at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1405)
????????at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:822
)
????????at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.ja
va:1446)
????????at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.jav
a:1371)
????????at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStateme
nt.java:1900)
???.......... and so on.....
When I have been removed relationships with another entity beans in my cantainer, create() method works correctly -- insert new string into my table. I have many such entity beans and I got one thing -- I may call create() method succesfully when current bean HAS NOT relationships FROM another beans...
I have not a relationship where the foreign keys are part of the primary keys in my case. I have simple integer primary and integer foreign key only.
When I have been turned on debug, I got next error message in jboss application server console:
2002-08-06 09:58:39,167 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.PmInfoVacations] Create: pk=61
2002-08-06 09:58:39,167 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.PmInfoVacations] Executing SQL: SELECT COUNT(*) FROM
PM_INFO_VACATIONS WHERE INFO_VACATION_ID=?
2002-08-06 09:58:39,628 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.PmInfoVacations] Executing SQL: INSERT INTO
PM_INFO_VACATIONS (INFO_VACATION_ID, CLOCK_NUMBER, LEAVE_DAYS, START_DATE, END_DATE, DECREE_NUMBER, DECREE_DATE, NOTES, LEAVE_KIND_ID,
CLOCK_NUMBER) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
2002-08-06 09:58:39,888 ERROR [org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.PmInfoVacations] Could not create entity
java.sql.SQLException: ORA-00957: duplicate column name
????????at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
Insert statement here is incorrect -- INFO_VACATION_ID is primary key in this table (Integer), first CLOCK_NUMBER - foreign key from another table, LEAVE_KIND_ID - foreign key to another table (it is unimportant in this case) and other fields -- just data. But what is second CLOCK_NUMBER field in this INSERT statement? First CLOCK_NUMBER - real field in the table, but second... Does anybody has any idea?
Is there any way to solve my problem?
If anyone can help it would be greatly appreciated.
?
總結
以上是生活随笔為你收集整理的SQL Error: 957, SQLState: 42000 ORA-00957: duplicate column name的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Java split拆分使用竖线为分隔符
- 下一篇: C# winform bin文件夹、ob