JDBI 中的事务传播
Transaction Propagation in JDBI
我在数据层使用JDBI,它没有使用spring。
在项目中,我从一个本身用 @Transaction
.
注释的方法中调用一个用 @Transaction
标记的方法
@Transaction
public void updateEmployee(Employee employee) {
employeeDao.update(employee);
departmentDao.updateDepartment(employee.getDepartment())
}
@Transaction
public void updateDepartment(Department department) {
...
}
我知道 Spring 的 @transaction
传播是如何工作的,但是在 JDBI 的情况下它是如何工作的?什么是默认传播级别?如果需要如何更改?
正如文档 https://jdbi.org/#_transactions 中所建议的那样,我们可以通过编程方式管理事务。但是想知道基于注释的配置中的行为。
在JDBI中,没有REQUIRED_NEW
的概念。这两个调用将 运行 在同一个事务中,
以下文字来自JDBI邮件组:
There's no concept of parking a transaction and starting a separate inner transaction automatically at this time, although of course, it's straightforward enough to do so manually with two Handles.
我在数据层使用JDBI,它没有使用spring。
在项目中,我从一个本身用 @Transaction
.
@Transaction
标记的方法
@Transaction
public void updateEmployee(Employee employee) {
employeeDao.update(employee);
departmentDao.updateDepartment(employee.getDepartment())
}
@Transaction
public void updateDepartment(Department department) {
...
}
我知道 Spring 的 @transaction
传播是如何工作的,但是在 JDBI 的情况下它是如何工作的?什么是默认传播级别?如果需要如何更改?
正如文档 https://jdbi.org/#_transactions 中所建议的那样,我们可以通过编程方式管理事务。但是想知道基于注释的配置中的行为。
在JDBI中,没有REQUIRED_NEW
的概念。这两个调用将 运行 在同一个事务中,
以下文字来自JDBI邮件组:
There's no concept of parking a transaction and starting a separate inner transaction automatically at this time, although of course, it's straightforward enough to do so manually with two Handles.