I was using hibernate 3.1.3 with informix 7.3 and I was mapping
"serial" column (auto generated column) using
"native" in my ".hbm.xml" file. This was working fine.
Hibernate used to "fire" query from "systab" table
to get the "auto generated serial key value"
But it stopped worked when i moved to informix 10.0.
(The exception stack trace is mentioned below)
Jdbc driver version 3.0 from ibm was used in both cases.
On debugging I saw that with "7.3" hibernate class: IdentifierGeneratorFactory was
trying to get "resultset.next" on "systab" query, but in 10.0
it was trying to "resultset.next" on the actual "insert" query.
Hibernate version: 3.1.3/3.2.0.cr4
Mapping documents: NA
Code between sessionFactory.openSession() and session.close():
NA
Full stack trace of any exception that occurs:
org.hibernate.HibernateException: The database returned no natively generated identity value
at org.hibernate.id.IdentifierGeneratorFactory.getGeneratedIdentity(IdentifierGeneratorFactory.java:33)
at org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:74)
at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:33)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2093)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2573)
at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:47)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:290)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:180)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:108)
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: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:
Informix 10
The generated SQL (show_sql=true):
RDBMS: Informix Dynamic Server, version: 10.00.FC3R1TL
Debug level Hibernate log excerpt:
[NFAPS] [] 02 Oct 2006 17:34:47,889 DEBUG (NullableType:80)- binding '2006-10-02 17:34:25' to parameter: 17
[NFAPS] [] 02 Oct 2006 17:35:03,123 DEBUG (AbstractBatcher:366)- about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
[NFAPS] [] 02 Oct 2006 17:35:03,139 DEBUG (AbstractBatcher:525)- closing statement
[NFAPS] [] 02 Oct 2006 17:35:03,154 DEBUG (ConnectionManager:398)- aggressively releasing JDBC connection
[NFAPS] [] 02 Oct 2006 17:35:03,154 DEBUG (ConnectionManager:435)- releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
[NFAPS] [] 02 Oct 2006 17:35:03,201 INFO (SchedulerUtil:192)- Error
org.hibernate.HibernateException: The database returned no natively generated identity value
at org.hibernate.id.IdentifierGeneratorFactory.getGeneratedIdentity(IdentifierGeneratorFactory.java:33)
Problems with Session and transaction handling?
Read this:
http://hibernate.org/42.html