Gallant
Gallant
业务场景:当前使用Springboot3.x,由mybatis转接入了Flex,需要扩展batchUpsertSelective功能(on duplicate key update批量性能更好),使用了Db.updateBySql功能,但是该功能使用的是自定义事务管理器,通常连接池的自动提交是关闭的:spring.datasource.hikari.auto-commit=false,因此我执行命令会发现数据没有写入到数据库,使用体验不好,迁移有兼容成本。而我想要对接Spring的事务管理器,目前实现起来很麻烦不够优雅,当前Db.invoker()开放了sqlSessionFactory的可配置化,但是没有放开可以配置sqlSession。如果放开可以无缝对接Spring事务管理。 当前对接方案伪代码如下: 1. 自定义RowMapperInvoker实现类重写execute,存在Spring的sqlSessionTemplate时优先使用Spring的管理的Session。 ``` protected R execute(Function function) { if (sqlSessionTemplate == null) { return super.execute(function); } Class currentType = MappedStatementTypes.getCurrentType(); if (currentType == null) {...