在使用mybatis和mysql(InnoDB)的springboot(1.5.7)中,当在一个方法中插入数据库时,一些操作成功,其中一个操作发生了数据截断异常。但是,成功的那些没有回滚,为什么?
有什么不对的吗?我无法找到任何关于春季交易的深入和全面的信息,有人知道或有吗?谢谢!
这是主要的应用程序
@SpringBootApplication
@MapperScan("com.demo.dao")
@EnableTransactionManagement
public class App {
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
}
这是服务
@Service
public class DemoServiceImpl implements DemoService {
@Autowired
private DemoMapper demoMapper;
@Transactional(propagation=Propagation.SUPPORTS,rollbackFor=Exception.class)
public void addInfo(List<EntityInfo> infos) {
demoMapper.insert(infos);
}
}
这是DemoMapper接口
public interface DemoMapper {
void insert(@Param("infos")List<EntityInfo> infos);
}
这是mapper.xml内容
<insert id="addInfos" parameterType="java.util.List">
<foreach collection="infos" item="info" open="" close="" separator=";">
INSERT INTO ....
</foreach>
</insert>
这是日志
2017-10-14 19:18:48.501 DEBUG 35894 --- [ main] t.a.AnnotationTransactionAttributeSource : Adding transactional method 'com.weiyan.risk.apply.service.impl.CreditServiceImpl.addCreditInfo' with attribute: PROPAGATION_REQUIRED,ISOLATION_DEFAULT; '',-java.lang.Exception
2017-10-14 19:18:48.496 DEBUG 35894 --- [ main] t.a.AnnotationTransactionAttributeSource : Adding transactional method 'com.weiyan.risk.apply.service.impl.ApplyServiceImpl.modifyApplyResult' with attribute: PROPAGATION_SUPPORTS,ISOLATION_DEFAULT; '',-java.lang.Exception
2017-10-14 19:19:40.620 TRACE 35894 --- [io-30200-exec-1] .s.t.s.TransactionSynchronizationManager : Initializing transaction synchronization
2017-10-14 19:19:40.620 TRACE 35894 --- [io-30200-exec-1] o.s.t.i.TransactionInterceptor : Getting transaction for [com.weiyan.risk.apply.service.impl.CreditServiceImpl.addCreditInfo]
2017-10-14 19:19:40.621 INFO 35894 --- [io-30200-exec-1] c.w.r.apply.aop.InterfaceLogInterceptor : 请求开始,方法:addInfos
2017-10-14 19:19:40.666 TRACE 35894 --- [io-30200-exec-1] .s.t.s.TransactionSynchronizationManager : Bound value [org.mybatis.spring.SqlSessionHolder@5bee83c] for key [org.apache.ibatis.session.defaults.DefaultSqlSessionFactory@6a075dde] to thread [http-nio-30200-exec-1]
...some long trace with attributes...
2017-10-14 19:19:40.761 INFO 35894 --- [io-30200-exec-1]
c.w.r.apply.aop.InterfaceLogInterceptor : exception:
org.springframework.dao.DataIntegrityViolationException:
### Error updating database. Cause:
com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'bank_cardno' at row 1
### The error may involve com.weiyan.risk.apply.dao.CreditMapper.addBanks-Inline
....stacktrace....
2017-10-14 19:19:40.763 TRACE 35894 --- [io-30200-exec-1] o.s.t.i.TransactionInterceptor : Completing transaction for [com.weiyan.risk.apply.service.impl.CreditServiceImpl.addCreditInfo]
2017-10-14 19:19:40.763 TRACE 35894 --- [io-30200-exec-1] .s.t.s.TransactionSynchronizationManager : Removed value [org.mybatis.spring.SqlSessionHolder@5bee83c] for key [org.apache.ibatis.session.defaults.DefaultSqlSessionFactory@6a075dde] from thread [http-nio-30200-exec-1]
....
2017-10-14 19:19:40.766 TRACE 35894 --- [io-30200-exec-1] .s.t.s.TransactionSynchronizationManager : Clearing transaction synchronization