简体   繁体   English

JDBI 中的事务传播

[英]Transaction Propagation in JDBI

I am using JDBI at the data layer, it doesn't use spring.我在数据层使用 JDBI,它不使用 spring。 In the project, I am calling a method which is marked with @Transaction from a method which itself is annotated with @Transaction .在项目中,我从一个本身用@Transaction注释的方法调用一个用@Transaction标记的方法。

@Transaction
public void updateEmployee(Employee employee) {
   employeeDao.update(employee);
   departmentDao.updateDepartment(employee.getDepartment())
} 

@Transaction
public void updateDepartment(Department department) {
  ...
}

I know how Spring's @transaction propagation works, but how does it work in the case of JDBI?我知道 Spring 的@transaction传播是如何工作的,但是在 JDBI 的情况下它是如何工作的呢? what is the default propagation level?什么是默认传播级别? How to change it if needed?如果需要如何更改?

As suggested in the docs https://jdbi.org/#_transactions we can manage transactions programmatically.正如文档https://jdbi.org/#_transactions中所建议的,我们可以以编程方式管理事务。 But would like to know behavior in the annotation-based configuration.但想知道基于注释的配置中的行为。

In JDBI, there is no concept of REQUIRED_NEW .在 JDBI 中,没有REQUIRED_NEW的概念。 Both the calls would run in a same transaction,两个调用都将在同一个事务中运行,

The below text is from the JDBI mailing group:以下文字来自 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.此时没有停止事务并自动启动单独的内部事务的概念,当然,使用两个句柄手动执行此操作很简单。

https://groups.google.com/d/msgid/jdbi/CAHjY6CVkSN%2BJ_KpEG_T1NXf%2B%2BwwOK7GxXz72ofs%2Bf_wONmL_Rw%40mail.gmail.com . https://groups.google.com/d/msgid/jdbi/CAHjY6CVkSN%2BJ_KpEG_T1NXf%2B%2BwwOK7GxXz72ofs%2Bf_wONmL_Rw%40mail.gmail.com .

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM