• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

mybatis autocommit always committing even when false

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Stop it! You're embarassing me! And you are embarrassing this tiny ad!
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic