I'm trying to insert into a table with a composite key. This key actually on has one key column, but it is set by the program when inserting.
Here is the mapping file.
Code:
<class name="com.dolby.ps.staging.db.model.PSStagingJournalHeader" table="DLB_PS_JRNL_HEADER" schema="dbo">
<composite-id unsaved-value="any">
<key-property column="JOURNAL_ID" name="journalID" type="string"></key-property>
</composite-id>
<property column="BUSINESS_UNIT" name="businessUnit" type="string"></property>
<property column="JOURNAL_DATE" name="journalDate" type="date"></property>
<property column="LEDGER_GROUP" name="ledgerGroup" type="string"></property>
<property column="SOURCE" name="source" type="string"></property>
<property column="DESCR" name="description" type="string"></property>
<property column="FOREIGN_CURRENCY" name="foreignCurrency" type="string"></property>
<property column="RT_TYPE" name="RTType" type="string"></property>
<property column="SYSTEM_SOURCE" name="systemSource" type="string"></property>
<property column="BUDGET_HDR_STATUS" name="budgetHeaderStatus" type="string"></property>
<property column="ADJUSTING_ENTRY" name="adjustingEntry" type="string"></property>
<property column="ACCOUNTING_PERIOD" name="accountingPeriod" type="short"></property>
<property column="REVERSAL_CD" name="reversalCode" type="string"></property>
<property column="REVERSAL_CD_ADB" name="reversalCodeADB" type="string"></property>
<property column="TRANS_REF_NUM" name="transactionRefNumber" type="string"></property>
<property column="CONVERSION_RATE" name="conversionRate" type="big_decimal"></property>
<property column="KK_AMOUNT_TYPE" name="KKAmountType" type="string"></property>
<property column="GL_ADJUST_TYPE" name="GLAdjustType" type="string"></property>
<property column="JOURNAL_CLASS" name="journalClass" type="string"></property>
<property column="PROCESS_STATUS" name="processStatus" type="string"></property>
<set name="lines" cascade="all" lazy="true">
<key column="JOURNAL_ID" />
<one-to-many class="com.dolby.ps.staging.db.model.PSStagingJournalLine" />
</set>
</class>
I've tried using both the jTDS driver and the MS SQLServerDriver.
here is the trace
Code:
17:15:35,107 ERROR SessionImpl:2375 - Could not synchronize database state with session
net.sf.hibernate.HibernateException: SQL insert, update or delete failed (row not found)
at net.sf.hibernate.impl.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:25)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:468)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:442)
at net.sf.hibernate.impl.ScheduledInsertion.execute(ScheduledInsertion.java:29)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2414)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2367)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2236)
at com.dolby.ps.staging.db.PeoplesoftJournalUK.create(PeoplesoftJournalUK.java:61)
at com.dolby.peoplesoft.test.Test.getPSStagingJournal(Test.java:164)
at com.dolby.peoplesoft.test.Test.main(Test.java:52)
17:15:35,107 DEBUG JDBCTransaction:82 - rollback
17:15:35,263 DEBUG SessionImpl:585 - transaction completion
17:15:35,279 ERROR Test:62 - Failed
com.dolby.ps.staging.db.PeoplesoftJournalException: An error has occurred creating journal
at com.dolby.ps.staging.db.PeoplesoftJournalUK.create(PeoplesoftJournalUK.java:107)
at com.dolby.peoplesoft.test.Test.getPSStagingJournal(Test.java:164)
at com.dolby.peoplesoft.test.Test.main(Test.java:52)
Caused by: net.sf.hibernate.HibernateException: SQL insert, update or delete failed (row not found)
at net.sf.hibernate.impl.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:25)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:468)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:442)
at net.sf.hibernate.impl.ScheduledInsertion.execute(ScheduledInsertion.java:29)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2414)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2367)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2236)
at com.dolby.ps.staging.db.PeoplesoftJournalUK.create(PeoplesoftJournalUK.java:61)
... 2 more
com.dolby.ps.staging.db.PeoplesoftJournalException: An error has occurred creating journal
at com.dolby.peoplesoft.test.Test.main(Test.java:63)
Caused by: net.sf.hibernate.HibernateException: SQL insert, update or delete failed (row not found)
at net.sf.hibernate.impl.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:25)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:468)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:442)
at net.sf.hibernate.impl.ScheduledInsertion.execute(ScheduledInsertion.java:29)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2414)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2367)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2236)
at com.dolby.ps.staging.db.PeoplesoftJournalUK.create(PeoplesoftJournalUK.java:61)
at com.dolby.peoplesoft.test.Test.getPSStagingJournal(Test.java:164)
at com.dolby.peoplesoft.test.Test.main(Test.java:52)
It seems that the update count is 0. Not sure how i can get the record to insert.
Anyone shed any light?
Thanks,
darren.