1 Reply Latest reply on Nov 23, 2003 6:21 AM by ivark

    How to disable autocommit for local-tx-datasource

    ivark

      Hi, I have a problem with my datasource-configuration (I think).
      I'm using the combination jboss-3.2.2/hibernate2/postgresql-7.3, and get a:

      [B]
      java.sql.SQLException: You cannot commit with autocommit set!
      at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.jdbcCommit(BaseWrapperManagedConnection.java:494)
      at org.jboss.resource.adapter.jdbc.WrappedConnection.commit(WrappedConnection.java:465)
      at net.sf.hibernate.id.TableGenerator.generate(TableGenerator.java:126)
      at net.sf.hibernate.id.TableHiLoGenerator.generate(TableHiLoGenerator.java:59)
      at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:599)
      ...
      ...
      [/B]

      ...each time I try to save an object. I've tried to setAutoCommit(false) on the WrappedConnection, but it didn't seem to help.

      Is there a way to configure the datasource so that it produces connections with autocommit disabled?

      My datasource-config looks like this:
      [B]
      <?xml version="1.0" encoding="UTF-8"?>

      <local-tx-datasource>
      <jndi-name>MyDS</jndi-name>
      <connection-url>jdbc:postgresql://localhost:5432/mydb</connection-url>
      <driver-class>org.postgresql.Driver</driver-class>
      <user-name>username</user-name>
      password
      </local-tx-datasource>

      [/B]
      -Marius

        • 1. Re: How to disable autocommit for local-tx-datasource
          ivark

          Hi again..
          I figured it out.
          I should have read the hibernate-documentation more closely.

          The Hibernate HiLo-generator is not compatible with JTA, since it uses a separate "non-rollback'able" connection for updating a special hilo-table when generating a new key. (I thougth it used the same connection)

          So. I changed to using sequence instead of hilo, and now it works like a charm...

          -Marius