Uploaded image for project: 'JBoss Enterprise Application Platform 4 and 5'
  1. JBoss Enterprise Application Platform 4 and 5
  2. JBPAPP-2408

Bug in DB2 9.7 driver affects Hibernate's "native" ID generator

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • EAP 5.0.1.CR1
    • 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
    • Hibernate
    • None
    • DB2 v9.7 , using its own driver

    • Workaround Exists
    • Hide

      1) If no LOBs are used by the application, the DB2 9.7 driver from Data Studio 2.2 can be used (see JBPAPP-2613)
      2) Use DB2 v9.1 driver, even if the server is DB2 v9.7.

      Note: When Version 9.1 JDBC is used with a 9.7 DB, only DB2 Version 9.1 or earlier functionality is available.
      ( http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/index.jsp?topic=/com.ibm.db2.luw.qb.upgrade.doc/doc/c0022579.html)

      3) When using the 9.7 driver(the "original" one or the one from Data Studio 2.2), and LOBs, create a property file named DB2JccConfiguration.properties and it should be on your class path or in a JAR which should also be on your classpath.
      then put this line below into that properties file
      "db2.jcc.override.progressiveStreaming=2"
      this will disable progressive streaming on DB2

      Show
      1) If no LOBs are used by the application, the DB2 9.7 driver from Data Studio 2.2 can be used (see JBPAPP-2613 ) 2) Use DB2 v9.1 driver, even if the server is DB2 v9.7. Note: When Version 9.1 JDBC is used with a 9.7 DB, only DB2 Version 9.1 or earlier functionality is available. ( http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/index.jsp?topic=/com.ibm.db2.luw.qb.upgrade.doc/doc/c0022579.html ) 3) When using the 9.7 driver(the "original" one or the one from Data Studio 2.2), and LOBs, create a property file named DB2JccConfiguration.properties and it should be on your class path or in a JAR which should also be on your classpath. then put this line below into that properties file "db2.jcc.override.progressiveStreaming=2" this will disable progressive streaming on DB2

    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())

      { long id = rs.getLong( 1 ); logger.info("ID is " + id); }

      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.

      Attachments

        Activity

          People

            jpkroehling@redhat.com Juraci Paixão Kröhling (Inactive)
            jpkroehling@redhat.com Juraci Paixão Kröhling (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: