wood burning stoves 2.0*
The moose likes Object Relational Mapping and the fly likes mybatis autocommit always committing even when false Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "mybatis autocommit always committing even when false" Watch "mybatis autocommit always committing even when false" New topic

mybatis autocommit always committing even when false

Vincent Sharma

Joined: Feb 20, 2013
Posts: 1
Hi, I'm trying to get my code to perform a number of inserts and commit at the very end if they all were successful. Here are the relevant mybatis config specs:

And here is a rough outline of the code:

session = sqlSessionFactory.openSession(false);

... insert A, insert B, insert C ...


...unless there is an exception...


However, when I try to call the session.commit(); it gives this error: "Operation Connection.commit is not allowed during a global transaction." and then when I check the table, the record is there. So it seems to have autocommitted.

I've tried setting <transactionManager type="EXTERNAL"> and it says it doesn't know what external is. If I set session = sqlSessionFactory.openSession(true); then I don't get an exception, but then it autocommits. What I am trying to do is to get it to only commit when I call session.commit() and then not commit anything if there is an exception and I call the rollback. Any help would be appreciated.

I agree. Here's the link: http://aspose.com/file-tools
subject: mybatis autocommit always committing even when false
Similar Threads
hibernat creating the tables without cascade
Migrating from Spring 2.0 and Hibernate 3.0 to Spring 3.1 and Hibernate 4.1
Spring JDBC Transaction
IBatis JNDI Issue
ibatis : how to set AutoCommit mode to false