Spring boot + MyBatisでWEBアプリ開発を行っております。
<開発マシン>
jdk:1.8.0.74
マシン:Windows7
IDE:eclipse4.4
ビルドツール:Gradle
・application.properties(抜粋)
#DB properties spring.datasource.url=jdbc:postgresql://XXX.XXX.XXX.XXX/db_name spring.datasource.username=user spring.datasource.password=password spring.datasource.driverClassName=org.postgresql.Driver #コネクションプール設定(default) spring.datasource.max-active=100 spring.datasource.max-idle=8 spring.datasource.min-idle=8 spring.datasource.initial-size=10 #セッションタイムアウトを1800秒とする。 spring.datasource.session-timeout=1800 #コネクションを利用する際に検証を行う。DBが再起動していてもこの処理を挟むことでtomcatを再起動しなくても済む spring.datasource.test-on-borrow=true spring.datasource.validation-query=SELECT 1 #コミットされずに残ったコネクションは60秒後に破棄される。 spring.datasource.remove-abandoned=true spring.datasource.remove-abandoned-timeout=60 spring.datasource.default-auto-commit=false mybatis.configuration.map-underscore-to-camel-case=true mybatis.configuration.call-setters-on-nulls=true mybatis.configuration.default-fetch-size=100 mybatis.configuration.default-statement-timeout=30 mybatis.configuration.localCacheScope=statement
ソース
@RequestMapping(value = "/user/home") @Transactional(readOnly = false) String home(Model model) throws ServletException { (中略) updateMTempUser.setErrStatus(ConstantCom.ERR_STATUS_OUT_OF_DATE); updateMTempUser.setRecordDate(new Date()); updateMTempUser.setRecordUserCd(userId); mTempUserMapper.updateByPrimaryKeySelective(updateMTempUser); throw new LimitOverException(Errors.LIMIT_OVER, getMessage("E.IIS.0000", "有効期限が切れています。userCd=" + userId)); (後略)
上記のようなソースでMapperでデータベース更新後、Exceptionをスローしているのですが、
トランザクションがコミットされてしまいます。
※テスト用のメソッドですので業務的な意味はありません。
デバッグ実行したところ、mTempUserMapper.updateByPrimaryKeySelective実行後には既にコミットされているようでした。
spring.datasource.default-auto-commit=false
を設定しているのでコミットされないと思っているのですが、うまくいかないようです。
何か見落としている点などがあるのでしょうか……。
上記のような現象に何か心当たりなどあるかたがおられましたら、
ご教授いただきたく思います。

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。