LoginSignup
0
1

More than 5 years have passed since last update.

MyBatisのcommit設定でハマった

Last updated at Posted at 2017-10-17

MyBatisでINSERT実行

ちょっとしたバッチの中でSELECTして加工したデータをMyBatisでINSERTしたかった

// まずMapperをSqlSessionから取得して
XXXMapper m = session.getMapper(XXXMapper.class);

System.out.print("Insert records...");

// Mapperに設定されてる関数からINSERT実行
m.insertByList(recordList);
System.out.println("OK!");

これでうまくいくはず…が、入らない…データが1つも入らない。

AutoCommitはデフォルトでOFF?

いろいろ検索してStackoverflowで同じような現象を見かけた

要は作成更新系のクエリを呼ぶときはcommit()を実行しろということ。普段はSpringのほうでトランザクション管理をしているので気づかなかった。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1