LoginSignup
0
0

More than 5 years have passed since last update.

Spring+Hibernate環境ではStaleObjectStateExceptionがcatchできない

Last updated at Posted at 2016-09-24

ググってもなかなかヒットしなかったので書き残す。

Hibernateは楽観的排他エラー検出時にorg.hibernate.StaleObjectStateExceptionをthrowするが、Spring環境ではorg.springframework.orm.ObjectOptimisticLockingFailureExceptionにラップして再throwされる。

参考:
Spring+Hibernate連携時の主なExceptionまとめ

SpringBootならObjectOptimisticLockingFailureExceptionをCatchすればいいですよ。
ORMがHibernateから別なORMに切り替わったとしても、Catch節を書き直さなくて済むようにラッピングしているのです。

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