There is an bug in InformixDialect preventing generator-class=native to work.

Description

When there is an column of SERIAL or SERIAL8 type (identity types in Informix) database expect this column to appear in INSERT clause with value equal 0, for example:
INSERT into my_table (my_serial_column, other_column) values (0, "some value"); - in this example my_serial_column is an identity column.

Using current InformixDialect this insert looks like this:
INSERT into my_table (other_column) values ( "some value");

which causes an exception:
java.sql.SQLException: Error In Specifying Automatically (Server) Generated Keys.
at com.informix.util.IfxErrMsg.getSQLException(IfxErrMsg.java:373)
at com.informix.jdbc.IfxSqli.a(IfxSqli.java:3208)
at com.informix.jdbc.IfxSqli.E(IfxSqli.java:3518)
at com.informix.jdbc.IfxSqli.dispatchMsg(IfxSqli.java:2353)
at com.informix.jdbc.IfxSqli.receiveMessage(IfxSqli.java:2269)
at com.informix.jdbc.IfxSqli.executePrepare(IfxSqli.java:1153)
at com.informix.jdbc.IfxPreparedStatement.e(IfxPreparedStatement.java:318)
at com.informix.jdbc.IfxPreparedStatement.a(IfxPreparedStatement.java:298)
at com.informix.jdbc.IfxPreparedStatement.<init>(IfxPreparedStatement.java:275)
at com.informix.jdbc.IfxSqliConnect.prepareStatement(IfxSqliConnect.java:2077)
at org.apache.commons.dbcp.DelegatingConnection.prepareStatement(DelegatingConnection.java:418)
at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.prepareStatement(PoolingDataSource.java:385)
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.hibernate.jdbc.BorrowedConnectionProxy.invoke(BorrowedConnectionProxy.java:40)
at $Proxy10.prepareStatement(Unknown Source)
...

I've tested a solution - dialect must redefine getIdentityInsertString method like this:

public String getIdentityInsertString() {
return "0";
}

After that identity column appear in INSERT clause with value set to 0.

I'am using hibernate version 3.1.3, but in the latest build 3.2.0.cr4 problem still exist (i've downloaded it and checked InformixDialect.java file).

Environment

hibernate version 3.1.3, IBM Informix Dynamic Server Version 10.00.FC3R1, JDBC IBM Informix driver ver 3.0.JC3 (ifxjdbc-3.0-jc3.jar)

Activity

Show:
zhangzhen
September 12, 2006, 9:32 AM

if use other informix driver for example informix driver for 9,this problem will not appear.

Max Rydahl Andersen
September 12, 2006, 9:51 AM

if i understand the issue then search for SERIAL8 in jira and you will see previous history for this.

especially since an updated driver seem to work fine ?

Zahid Shaikh
October 19, 2006, 11:21 PM

I have the same issue.. I am using informix 10.. As far as I know 3.0.JC3 is the latest.

If I use "old driver" then i am sure that it will fire "extra" query from "systab" table to get the PK.(ie not optimized)

Zahid Shaikh
December 17, 2006, 2:24 AM

I talked with IBM guys.. They said the bug is their on a particular version of Informix 10. I then tried with latest informix 10 version and this issue went away.

Assignee

Unassigned

Reporter

Andrew from Poland

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Minor
Configure