lbitonti / liquibase-hana

Liquibase Hana extension
Apache License 2.0
11 stars 11 forks source link

DB-Connection is set to autocommit mode which breaks manual commit #15

Open pichlerm opened 6 years ago

pichlerm commented 6 years ago

We use Liquibase together with Hibernate transaction handling in an application. Hibernate expects DB connections to be not in autocommit mode.

liquibase.database.ext.HanaDBDatabase#supportsDDLInTransaction returns false which causes getAutoCommitMode() of the base class to return true, used in setConnection(DatabaseConnection) where connection.setAutoCommit is set on the DatabaseConnection - true in case of the HanaDB. When the same DB-connection is used by Hibernate and explicitly committed at the end of a transaction, the Hana JDBC driver throws an exception: com.sap.db.jdbc.exceptions.JDBCDriverException: SAP DBTech JDBC: Connection is currently in auto commit mode.

Our workaround was to override HanaDBDatabase#getAutoCommitMode() to return false.

Possilby supportsDDLInTransaction might return true (like for Oracle and MS-SQL). You refer to http://help.sap.com/saphelp_hanaplatform/helpdata/en/20/fdf9cb75191014b85aaa9dec841291/content.htm

However there is also a SET TRANSACTION AUTOCOMMIT DDL statement which claims that rollbacks of DDL statements are supported. https://help.sap.com/viewer/4fe29514fd584807ac9f2a04f6754767/2.0.00/en-US/d538d11053bd4f3f847ec5ce817a3d4c.html

Not sure, which one is true, and where the SET TRANSACTION AUTOCOMMIT DDL ON had to be placed. Also not sure, which side effects the return false by HanaDBDatabase#getAutoCommitMode() might cause.