-->
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.  [ 4 posts ] 
Author Message
 Post subject: hibernate 3.1/3.2 does not work with informix 10 for insert
PostPosted: Tue Oct 03, 2006 11:12 am 
Newbie

Joined: Mon Oct 02, 2006 5:43 pm
Posts: 4
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


Top
 Profile  
 
 Post subject: futher info..
PostPosted: Tue Oct 03, 2006 5:45 pm 
Newbie

Joined: Mon Oct 02, 2006 5:43 pm
Posts: 4
On further debugging, I found that with informix
7.3 the Databasemetada value for "supportsGetGeneratedKeys"
was returning false.

But with informix 10 and IBM jdbc driver(JDBC.3.00.JC3 )
the above method returned true. But it failed to get any value
on invoking "getGeneratedKeys" on the statement object.


Last edited by zahidncst on Wed Oct 04, 2006 10:20 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: futher info..
PostPosted: Wed Oct 04, 2006 10:17 am 
Newbie

Joined: Mon Oct 02, 2006 5:43 pm
Posts: 4
I am still waiting on reply. My guess is somehow the hibernate
code should call "stmt.getSerial" (instead of getGeneratedKey)
or alternatively provide a factility to disable "getGeneratedKey"

I found out that the "serial" column is not a part of the "insert sql"
query. Hence there is a bug in jdbc driver(which i informed ibm)
that results in "getGeneratedKey" not working.

For now, I will modify hibernate's IdentityGenerator.java so
that it does not call "getGeneratedKey" and use "getSerial"
instead.

-Zahid Shaikh


Top
 Profile  
 
 Post subject: it works with lastest informix 10
PostPosted: Sun Feb 18, 2007 11:23 pm 
Newbie

Joined: Mon Oct 02, 2006 5:43 pm
Posts: 4
IBM told me to use latest version of informix 10 server. And the bug went away.


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