Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transaction.rollback causes java.sql.SQLException #20

Open
joa opened this issue May 2, 2011 · 0 comments
Open

Transaction.rollback causes java.sql.SQLException #20

joa opened this issue May 2, 2011 · 0 comments

Comments

@joa
Copy link

joa commented May 2, 2011

Please see inline comments.
Code will result in "java.sql.SQLException: Can't call commit when autocommit=true"

def test(): Boolean =
  queryEvaluator.transaction {
    t => {
      t.execute("SELECT 1")
      t.execute("SELECT 1")

      val everythingWentSuccessful = false

      if(everythingWentSuccessful) {
        true
      } else {
        t.rollback()//causes the Transaction to be rolled back, autoCommit will be set to true
        false
      }
    } // no exception occurred so query evaluator will call commit on the transaction which yields exception
}

It seems to me the only way to roll back a transaction right now is to
a) raise an error
b) set auto commit to false after calling rollback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant