-->
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.  [ 8 posts ] 
Author Message
 Post subject: Cannot insert into a table with a composite-id
PostPosted: Mon Aug 02, 2004 12:33 pm 
Beginner
Beginner

Joined: Sun Jun 13, 2004 9:49 pm
Posts: 38
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.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 03, 2004 5:44 am 
Beginner
Beginner

Joined: Sun Jun 13, 2004 9:49 pm
Posts: 38
Has noone ever done this. These tables were created by the Peoplesoft consultants and I have to fill them.

I just cannot seem to get pas this error. I must be doing something wrong.

Thanks
Darren.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 03, 2004 5:54 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
It's not a composite-id if it has one column, its an application "assigned" id. Use the "assigned" id generator as documented.

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


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 05, 2004 3:01 am 
Beginner
Beginner

Joined: Sun Jun 13, 2004 9:49 pm
Posts: 38
I would normally agree there, but this is column that has to be assigned by the application. Is there a way to do that?

Basically it is a 10 char field made up of 'UKM' + 0410 + 001
UKM is static, then the year/month and then an incrementing number within the year and month.

Is there a way of telling hibernate to use a stored procedure to get the next id? This would be really helpful.

Thanks,

Darren


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 05, 2004 3:30 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Um. Do you understand what Christian just advised you to do??


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 05, 2004 7:41 am 
Beginner
Beginner

Joined: Sun Jun 13, 2004 9:49 pm
Posts: 38
Oh dear. After reading your post gavin, i really should read more carefully.
I re-read and understand now. Just looked at the reference guide and found it.

But, if i do have a table with a composite-id, how do i insert rows?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 05, 2004 7:43 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
http://www.hibernate.org/hib_docs/refer ... ompositeid

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


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 05, 2004 10:36 am 
Expert
Expert

Joined: Fri Feb 06, 2004 7:49 am
Posts: 255
Location: Moscow, Russia
Kango wrote:
But, if i do have a table with a composite-id, how do i insert rows?


*lowly* :)
http://www.hibernate.org/116.html#A11


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