【发布时间】:2020-04-02 16:03:32
【问题描述】:
我不明白以下行为:
我有一个方法:
@Transactional
public void processRejection(final Path path) {
try {
//some code here
} catch (final Exception e) {
this.handleException(e));
}
}
它调用下面的 saves 一个在数据库中尚不存在的实体:
void handleException(final Throwable e) {
this.filesMonitoringJpaManager.save(someEntityHere);
throw new Exception(...)
}
现在奇怪的是,当我评论 throw new Exception(...) save 有效,但是当我取消评论 throw new Exception(...) 然后save 无效我不知道为什么?
JPA 或 Hibernate 有什么奇怪的行为?是不是关于Java Exception机制的东西我不明白?
【问题讨论】:
标签: java spring database hibernate spring-boot