This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
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 OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA 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
Author

mybatis autocommit always committing even when false

Vincent Sharma
Greenhorn

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 ...

session.commit();

...unless there is an exception...

session.rollback(true);


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.

Vincent
 
jQuery in Action, 2nd edition
 
subject: mybatis autocommit always committing even when false