开发者

@Transactional rollbackFor question

Supposing I mark a method @Transactional(rollbackFor = PersistenceException.class) in my Service layer and have a catch block as follows within开发者_运维问答 the method.

try{
    serverStore.update(persistableObject);
     } catch (PersistenceException e) {

}

Will I ever even catch the PersistenceException?

I ask because the Persistence exception I'm guarding for is an intermittent deadlocking issue and I can't tell if I just haven't reproduced it since this change or it's not supposed to show up.


It depends on how you flush the session (entity manager). By default, I think, it will get flush when the transaction is committed, so you won't be able to catch the exception in the method.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜