quarkus - Quarkus:回滚哪些异常?
问题描述
我认为 @Transaction 中的 RuntimeExceptions 不会导致还原和检查异常。
例如我有两个类:
A:
@POST
@Path( DO_SOMETHING )
@Consumes( MediaType.APPLICATION_JSON )
@Produces( { MediaType.APPLICATION_JSON } )
@Authenticated
public RestResponse doSomething( SetttingsDTO settings ) {
Response eok = new Response();
try {
b.callMe( settings );
eok.setResponse( "Successfull", null );
} catch ( Exception ex ) {
log.error( ex.getMessage() );
eok.setResponse( ex );
}
return eok;
}
B类:
@Transactional
public void callMe( SetttingsDTO settings ) throws Exception {
/*
Here we do some things in the database
*/
throw new IOException("Test");
}
据我了解,因为在 A 类中抛出并捕获了 IOException,所以数据库不应返回数据库更改。但实际上数据库确实恢复了。尽管捕获了异常,但我的数据库更改已写入数据库。
有人可以解释为什么吗?
解决方案
推荐阅读
- c# - 使用 Moq 进行模拟时,Mock 返回 null
- java - 如何同时使用两个单独的 Spring yaml 配置文件?
- mysql - MySQL 计数不同并显示其标签
- python - 使用 Python 设置网络爬虫时遇到问题
- javascript - 为什么我在 Chrome 扩展的选项卡的内容中找不到子字符串
- flutter - 使用 dart:HTML 库在 Flutter Web 中选择文件时如何获取 Flutter 中的文件名?
- python - 在 Python 中实现 Stack 的 BFS 二叉树
- node.js - Elasticsearch 查询包括它应该排除的文档,反之亦然
- python - 如何使用开发标记文件进行预测和测试标记文件以进行验证?
- google-cloud-platform - 如何使用 Google 部署管理器 (Python + YAML) 部署内部 HTTP(S) 负载平衡器?