Details
-
Bug
-
Resolution: Done
-
Major
-
EAP 5.0.0.CR1, EAP 5.0.0.BETA, EAP 5.0.0.CR2, EAP 5.0.0.CR3, EAP 5.0.0.CR4 (FCS and BETA2), EAP 5.0.0.CR5
-
None
-
DB2 v9.7 , using its own driver
-
Workaround Exists
-
Description
There seems to be an issue with the DB2 v9.7 JDBC driver, which affects Hibernate when using "native" ID generator. This generator uses "identity" in DB2 and uses the Statement.getGeneratedKeys() to get a resultset of ID's generated for the insert, but DB2 driver is returning an empty set. Thus, Hibernate complains that "The database returned no natively generated identity value" .
A simple test case makes it evident (and is a simplification of what Hibernate does):
con = DriverManager.getConnection(getUrl(), getUsername(), getPassword());
PreparedStatement insert = con.prepareStatement("insert into mytable (coluna) values ('bla')", PreparedStatement.RETURN_GENERATED_KEYS);
insert.executeUpdate();
ResultSet rs = insert.getGeneratedKeys();
if (rs.next())
else
{ logger.error("There's no next!"); }With 9.1 driver, the ID is printed out. With the 9.7 driver, the "There's no next" is printed.