-->
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: Issue with sybase identity column
PostPosted: Fri Nov 25, 2005 1:41 pm 
Newbie

Joined: Thu Jun 17, 2004 4:19 pm
Posts: 3
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3.0

Mapping documents:
<hibernate-mapping>
<class name="com.gs.ir.irfeeds.db.CurrencyFeedStaging" table="CurrencyFeedStaging" >
<id name="id" type="long" column="id" unsaved-value="0" >
<generator class="identity"/>
</id>
<property name="toCurrencyCode" type="string" column="currency_code_to" />
<property name="fromCurrencyCode" type="string" column="currency_code_from" />
<property name="updateDate" type="timestamp" column="update_date" />
<property name="rate" type="big_decimal" column="rate" />
<property name="dataSource" type="string" column="data_source" />
<property name="status" type="string" column="status" />
</class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:
Hibernate: insert into CurrencyFeedStaging (currency_code_to, currency_code_from, update_date, rate, data_source, status, id) values (?, ?, ?, ?, ?, ?, null)
Fri Nov 25 12:37:54 EST 2005 DEBUG [main] preparing statement
Fri Nov 25 12:37:54 EST 2005 DEBUG [main] Dehydrating entity: [com.gs.ir.irfeeds.db.CurrencyFeedStaging#<null>]
Fri Nov 25 12:37:54 EST 2005 DEBUG [main] binding 'USD' to parameter: 1
Fri Nov 25 12:37:54 EST 2005 DEBUG [main] binding 'ALL' to parameter: 2
Fri Nov 25 12:37:54 EST 2005 DEBUG [main] binding '2005-11-25 12:37:44' to parameter: 3
Fri Nov 25 12:37:54 EST 2005 DEBUG [main] binding '0.00955292' to parameter: 4
Fri Nov 25 12:37:54 EST 2005 DEBUG [main] binding 'CornerStone' to parameter: 5
Fri Nov 25 12:37:54 EST 2005 DEBUG [main] binding 'A' to parameter: 6
Fri Nov 25 12:37:54 EST 2005 DEBUG [main] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
Fri Nov 25 12:37:54 EST 2005 DEBUG [main] closing statement
Fri Nov 25 12:37:54 EST 2005 DEBUG [main] could not insert: [com.gs.ir.irfeeds.db.CurrencyFeedStaging] [insert into CurrencyFeedStaging (currency_code_to, currency_code_from, update_date, rate, data_source, status, id) values (?, ?, ?, ?, ?, ?, null)]
com.sybase.jdbc2.jdbc.SybSQLException: The column id in table CurrencyFeedStaging does not allow null values.

at com.sybase.jdbc2.tds.Tds.processEed(Tds.java:2408)
at com.sybase.jdbc2.tds.Tds.nextResult(Tds.java:1844)
at com.sybase.jdbc2.jdbc.ResultGetter.nextResult(ResultGetter.java:69)
at com.sybase.jdbc2.jdbc.SybStatement.nextResult(SybStatement.java:201)
at com.sybase.jdbc2.jdbc.SybStatement.nextResult(SybStatement.java:182)
at com.sybase.jdbc2.jdbc.SybStatement.updateLoop(SybStatement.java:1479)
at com.sybase.jdbc2.jdbc.SybStatement.executeUpdate(SybStatement.java:1462)
at com.sybase.jdbc2.jdbc.SybPreparedStatement.executeUpdate(SybPreparedStatement.java:88)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:1975)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2404)
at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:37)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:243)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:269)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:167)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:101)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
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:524)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:514)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:510)
at com.gs.ir.utils.HibernateDataBaseManager.hibernateInsert(HibernateDataBaseManager.java:328)
at com.gs.ir.utils.HibernateDataBaseManager.insert(HibernateDataBaseManager.java:106)
at com.gs.ir.utils.HibernateDataBaseManager.performAction(HibernateDataBaseManager.java:207)
at com.gs.ir.utils.HibernateDataBaseManager.performVOTransaction(HibernateDataBaseManager.java:179)
at com.gs.ir.irfeeds.dao.CurrencyFeedStagingDAO.add(CurrencyFeedStagingDAO.java:46)
at com.gs.ir.exchrates.api.LoadExchangeRatesStagingData.stageExchangeRatesInDB(LoadExchangeRatesStagingData.java:105)
at com.gs.ir.exchrates.api.LoadExchangeRatesStagingData.parseExchangeRateDataFile(LoadExchangeRatesStagingData.java:63)
at com.gs.ir.exchrates.api.LoadExchangeRatesStagingData.process(LoadExchangeRatesStagingData.java:30)
at com.gs.ir.exchrates.api.LoadExchangeRatesStagingData.main(LoadExchangeRatesStagingData.java:127)
Fri Nov 25 12:37:54 EST 2005 WARN [main] SQL Error: 233, SQLState: 23000
Fri Nov 25 12:37:54 EST 2005 ERROR [main] The column id in table CurrencyFeedStaging does not allow null values.

Fri Nov 25 12:37:54 EST 2005 ERROR [main] ERROR: Critical Database Operation Error.; nested exception is:
com.gs.ir.exceptions.HibernateDataBaseException: ERROR: During Insert operation.; nested exception is:
org.hibernate.exception.ConstraintViolationException: could not insert: [com.gs.ir.irfeeds.db.CurrencyFeedStaging]
Fri Nov 25 12:37:54 EST 2005 DEBUG [main] commit
Fri Nov 25 12:37:54 EST 2005 DEBUG [main] automatically flushing session
Fri Nov 25 12:37:54 EST 2005 DEBUG [main] flushing session
Fri Nov 25 12:37:54 EST 2005 DEBUG [main] processing flush-time cascades
Fri Nov 25 12:37:54 EST 2005 DEBUG [main] dirty checking collections
Fri Nov 25 12:37:54 EST 2005 DEBUG [main] Flushing entities and processing referenced collections
Fri Nov 25 12:37:54 EST 2005 ERROR [main] an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
org.hibernate.AssertionFailure: null id in com.gs.ir.irfeeds.db.CurrencyFeedStaging entry (don't flush the Session after an exception occurs)
at org.hibernate.event.def.DefaultFlushEntityEventListener.checkId(DefaultFlushEntityEventListener.java:48)
at org.hibernate.event.def.DefaultFlushEntityEventListener.getValues(DefaultFlushEntityEventListener.java:140)
at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:97)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:195)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:905)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:345)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at com.gs.ir.utils.HibernateDataBaseManager.hibernateFinishTran(HibernateDataBaseManager.java:506)
at com.gs.ir.utils.HibernateDataBaseManager.commitTran(HibernateDataBaseManager.java:136)
at com.gs.ir.utils.HibernateDataBaseManager.performVOTransaction(HibernateDataBaseManager.java:188)
at com.gs.ir.irfeeds.dao.CurrencyFeedStagingDAO.add(CurrencyFeedStagingDAO.java:46)
at com.gs.ir.exchrates.api.LoadExchangeRatesStagingData.stageExchangeRatesInDB(LoadExchangeRatesStagingData.java:105)
at com.gs.ir.exchrates.api.LoadExchangeRatesStagingData.parseExchangeRateDataFile(LoadExchangeRatesStagingData.java:63)
at com.gs.ir.exchrates.api.LoadExchangeRatesStagingData.process(LoadExchangeRatesStagingData.java:30)
at com.gs.ir.exchrates.api.LoadExchangeRatesStagingData.main(LoadExchangeRatesStagingData.java:127)
org.hibernate.AssertionFailure: null id in com.gs.ir.irfeeds.db.CurrencyFeedStaging entry (don't flush the Session after an exception occurs)
at org.hibernate.event.def.DefaultFlushEntityEventListener.checkId(DefaultFlushEntityEventListener.java:48)
at org.hibernate.event.def.DefaultFlushEntityEventListener.getValues(DefaultFlushEntityEventListener.java:140)
at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:97)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:195)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:905)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:345)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at com.gs.ir.utils.HibernateDataBaseManager.hibernateFinishTran(HibernateDataBaseManager.java:506)
at com.gs.ir.utils.HibernateDataBaseManager.commitTran(HibernateDataBaseManager.java:136)
at com.gs.ir.utils.HibernateDataBaseManager.performVOTransaction(HibernateDataBaseManager.java:188)
at com.gs.ir.irfeeds.dao.CurrencyFeedStagingDAO.add(CurrencyFeedStagingDAO.java:46)
at com.gs.ir.exchrates.api.LoadExchangeRatesStagingData.stageExchangeRatesInDB(LoadExchangeRatesStagingData.java:105)
at com.gs.ir.exchrates.api.LoadExchangeRatesStagingData.parseExchangeRateDataFile(LoadExchangeRatesStagingData.java:63)
at com.gs.ir.exchrates.api.LoadExchangeRatesStagingData.process(LoadExchangeRatesStagingData.java:30)
at com.gs.ir.exchrates.api.LoadExchangeRatesStagingData.main(LoadExchangeRatesStagingData.java:127)



Name and version of the database you are using:
Sybase: 12.5



The generated SQL (show_sql=true): in exception above

Debug level Hibernate log excerpt:DEBUG


I seem to be having an issue inserting the row into Sybase - the table has an identity column.
Table definition :
CREATE TABLE CurrencyFeedStaging
(
id numeric(18,0) IDENTITY,
currency_code_from varchar(5),
currency_code_to varchar(5),
update_date datetime,
rate numeric(14,6),
data_source varchar(20),
status char(1)
)
go


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 27, 2005 5:15 pm 
Regular
Regular

Joined: Fri Sep 09, 2005 11:35 am
Posts: 101
change the unsaved-value attribute of identity column to something other than 0


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.