-->
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: bug in Hibernate3.0.5 for Informix 7.3 with native id gen?
PostPosted: Mon Jul 04, 2005 6:46 am 
Newbie

Joined: Mon Jul 04, 2005 6:29 am
Posts: 4
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
3.0.5
Mapping documents:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping package="mt.domain">

<class
name="User"
table="mtil_gebruikers"
>
<id
name="userId"
column="gbc"
>
<generator class="assigned"/>
</id>

<property name="paswoord"/>
<property name="groep" column="co_groep"/>

<!-- we fetchen de mestBankNummers eagerly
omdat de user bij login loaden op PK en hem dan in de HttpSession
steken en we willen die mestbanknummers er dan ook bij. -->
<set name="mestBankNummers" lazy="false">
<key column="gbc"/>
<one-to-many class="MestBankNummer"/>
</set>
</class>

<class
name="MestBankNummer"
table="mtil_bevoegdheden"
where="actief='j' or actief='J'"
>
<composite-id>
<key-property name="userId" column="gbc"/>
<key-property name="mestBankNummer" column="mbnr"/>
</composite-id>

<property name="actief" />
</class>

<class name="Klant" table="klantenbestand">
<cache usage="read-write"/>
<id name="id" column="techid">
<!--<generator class="identity"/>-->
<generator class="native"/>
</id>

<property name="userId" column="userId"/>
<property name="mestBankNummer" column="mestbanknummer"/>
<property name="rol" column="ind_ab_af_vv" />

<property name="naam" />
<property name="creationDate" column="datum_creatie"/>
<property name="lastUsedDate" column="datum_laatst"/>
</class>
</hibernate-mapping>



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


Full stack trace of any exception that occurs:

Caused by: org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not insert: [mt.domain.Klant]: encountered SQLException [Borrow prepareStatement from pool failed]; nested exception is org.apache.commons.dbcp.SQLNestedException: Borrow prepareStatement from pool failed

at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.translate(SQLStateSQLExceptionTranslator.java:93)

at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.translate(SQLErrorCodeSQLExceptionTranslator.java:257)

at org.springframework.orm.hibernate3.HibernateAccessor.convertJdbcAccessException(HibernateAccessor.java:279)

at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:266)

at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:317)

at org.springframework.orm.hibernate3.HibernateTemplate.saveOrUpdate(HibernateTemplate.java:612)

at mt.dao.KlantDaoImpl.saveKlant(KlantDaoImpl.java:42)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:585)

at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:288)

at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:155)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:122)

at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:57)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)

at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:174)

at $Proxy6.saveKlant(Unknown Source)

at mt.service.MADStateServiceImpl.updateKlantenBestand(MADStateServiceImpl.java:327)

at mt.service.MADStateServiceImpl.changeMadStatus(MADStateServiceImpl.java:116)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:585)

at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:288)

at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:155)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:122)

at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:57)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)

at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:174)

at $Proxy12.changeMadStatus(Unknown Source)

at mt.service.InvullenServiceImpl.saveMADData(InvullenServiceImpl.java:1155)

at mt.web.Invullen2Form.submit(Invullen2Form.java:147)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:585)

at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:126)

... 29 more

Caused by: org.apache.commons.dbcp.SQLNestedException: Borrow prepareStatement from pool failed

at org.apache.commons.dbcp.PoolingConnection.prepareStatement(PoolingConnection.java:93)

at org.apache.commons.dbcp.DelegatingConnection.prepareStatement(DelegatingConnection.java:185)

at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.prepareStatement(PoolingDataSource.java:278)

at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:396)

at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:76)

at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:69)

at org.hibernate.id.AbstractPostInsertGenerator.getGenerated(AbstractPostInsertGenerator.java:39)

at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:1785)

at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:2178)

at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:34)

at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:239)

at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:240)

at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:160)

at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:95)

at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:184)

at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:173)

at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:96)

at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:69)

at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:468)

at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:463)

at org.springframework.orm.hibernate3.HibernateTemplate$18.doInHibernate(HibernateTemplate.java:615)

at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:312)

... 62 more

Caused by: java.sql.SQLException: Unknown first argument of dbinfo(serial8).

at com.informix.jdbc.IfxSqli.addException(IfxSqli.java:3082)

at com.informix.jdbc.IfxSqli.receiveError(IfxSqli.java:3396)

at com.informix.jdbc.IfxSqli.dispatchMsg(IfxSqli.java:2259)

at com.informix.jdbc.IfxSqli.receiveMessage(IfxSqli.java:2179)

at com.informix.jdbc.IfxSqli.executePrepare(IfxSqli.java:1082)

at com.informix.jdbc.IfxResultSet.executePrepare(IfxResultSet.java:182)

at com.informix.jdbc.IfxPreparedStatement.setupExecutePrepare(IfxPreparedStatement.java:197)

at com.informix.jdbc.IfxPreparedStatement.<init>(IfxPreparedStatement.java:175)

at com.informix.jdbc.IfxSqliConnect.prepareStatement(IfxSqliConnect.java:1907)

at org.apache.commons.dbcp.PoolingConnection.makeObject(PoolingConnection.java:188)

at org.apache.commons.pool.impl.GenericKeyedObjectPool.borrowObject(GenericKeyedObjectPool.java:747)

at org.apache.commons.dbcp.PoolingConnection.prepareStatement(PoolingConnection.java:87)

... 83 more



Name and version of the database you are using:
INFORMIX-OnLine
7.31.UC4
IBM Informix JDBC Driver for IBM Informix Dynamic Server
2.21.JC5

The generated SQL (show_sql=true):
Hibernate: update klantenbestand set userId=?, mestbanknummer=?, ind_ab_af_vv=?, naam=?, datum_creatie=?, datum_laatst=? where techid=?

Hibernate: select klant0_.techid as techid, klant0_.userId as userId21_, klant0_.mestbanknummer as mestbank3_21_, klant0_.ind_ab_af_vv as ind4_21_, klant0_.naam as naam21_, klant0_.datum_creatie as datum6_21_, klant0_.datum_laatst as datum7_21_ from klantenbestand klant0_ where klant0_.userId=? and klant0_.ind_ab_af_vv=? and klant0_.mestbanknummer=?

Hibernate: insert into klantenbestand (userId, mestbanknummer, ind_ab_af_vv, naam, datum_creatie, datum_laatst) values (?, ?, ?, ?, ?, ?)

Hibernate: select dbinfo('serial8') from systables where tabid=1


Debug level Hibernate log excerpt:




With Hibernate3.0.5 native id generation with informix 7.3 doens't seem to work anymore. This worked fine with Hibernate2.1.8 (I switched from Hibernate2.1.8 on this project)!

Please help because I am really blocked by this!!!

Tx!


Top
 Profile  
 
 Post subject: idea of the bug
PostPosted: Mon Jul 04, 2005 8:08 am 
Newbie

Joined: Mon Jul 04, 2005 6:29 am
Posts: 4
note that the type of the id column is SERIAL and not SERIAL8
=> the generated SQL should contain dbinfo('sqlca.sqlerrd1') and not dbinfo('serial8')


I somebody could tell me in which java class this SQL is generated I could fix it myself.

Tx.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 04, 2005 8:47 am 
Regular
Regular

Joined: Tue Oct 28, 2003 8:25 am
Posts: 72
Location: Belgium
Have a look at the dialect class:

org.hibernate.dialect.InformixDialect

Methods getIdentitySelectString() and getIdentityColumnString() contains PK generation code.

This seems to be related to an SQL type check: java.sql.Types.BIGINT type will give you the incorrect SQL statement.

I know nothing about informix but a wild guess makes me think this could be related to informix version ? I mean could that be that a more recent informix version support this dbinfo('serial8') feature ?


Top
 Profile  
 
 Post subject: found it
PostPosted: Mon Jul 04, 2005 9:31 am 
Newbie

Joined: Mon Jul 04, 2005 6:29 am
Posts: 4
Hi,
There is no bug in Hibernate. The problem was mine (but worked in Hibernate2.1.8). I was using a Long java type for the id field and Hibernate correctly mapped this onto the Informix type SERIAL8 (which is 10 bytes long). The informix type SERIAL is only 4 bytes long, so a java Integer should suffice. I switched from Long to Integer and then the correct sql was generated.


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.