我在服务对象中有一个方法,它组成了应该包装在事务中的操作。其中一些操作也包装在事务中。例如:
class PostCreator
def create
ActiveRecord::Base.transaction do
post.do_this
post.do_that
user.do_more(post, other_stuff)
end
end
end
def Post
def do_this
transaction do; ...; end
end
end
我需要任何嵌套故障
我用的是spring boot和mybatis MyBatisBatchItemWriter。使用demo将数据(Mysql)写入数据库,当没有问题时。但在我的项目org.springframework.dao.TransientDataAccessResourceException: Cannot change the ExecutorType when there is an existing transaction at org.mybatis.spring.SqlSessionUtils.getSqlSession(SqlSessionUtils.java:91) ~[myba
我的DAO接口很简单:
import org.springframework.transaction.annotation.Transactional;
@Component
@Transactional
public interface TTestDao {
@Transactional()
public void first();
@Transactional(propagation=Propagation.REQUIRES_NEW)
public void second() ;
}
ad方法:
@Override
public void first
我想要解决的问题的背景:我有一个java spring http拦截器AuditHttpCommunicationInterceptor,它审计与外部系统的通信。执行通信的HttpClieant在java服务类中使用,该服务类执行一些称为DoBusinessLogicSevice的业务逻辑。DoBusinessLogicSevice打开一个新事务,使用几个协作者完成大量工作。
要解决的问题:无论DoBusinessLogicSevice中任何操作的结果如何(意外异常等),我都希望AuditHttpCommunicationInterceptor将审计结果存储在数据库中。
我使用的解决方案: A
我在生产上有奇怪的行为。
第一次用户请求通过应用程序失败,我得到了“锁定请求超时超过了”的SQLServerException。在此之后,成功执行以下请求。过了一段时间,我关闭了客户端应用程序,所有请求都消失了。我知道请求是成功执行的,因为我在客户端应用程序上有JDBC日志记录。
除了嵌套事务和回滚之外,还有其他可能的场景吗?
当可能时,连接池使用相同的spid (会话),所以这里肯定是这样的。
每个请求只是一个存储过程,它定义了显式事务。我不知道这是如何发生的,因为事务要么是提交的,要么是因为这个块而回滚的。
begin try
begin tran
set lock_timeo