修复银行流水批量入库MySQL1869异常

This commit is contained in:
wkc
2026-03-20 17:06:18 +08:00
parent 4e4af5d9fb
commit 1958a00ce6
3 changed files with 66 additions and 1 deletions

View File

@@ -403,7 +403,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
)
</foreach>
on duplicate key update
bank_statement_id = bank_statement_id
batch_id = batch_id
</insert>
<delete id="deleteByProjectIdAndBatchId">

View File

@@ -132,6 +132,17 @@ class CcdiBankStatementMapperXmlTest {
}
}
@Test
void insertBatch_shouldAvoidUpdatingAutoIncrementPrimaryKeyInDuplicateBranch() throws Exception {
try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream(RESOURCE)) {
String xml = new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
assertTrue(xml.contains("on duplicate key update"), xml);
assertTrue(xml.contains("batch_id = batch_id"), xml);
assertFalse(xml.contains("bank_statement_id = bank_statement_id"), xml);
}
}
private MappedStatement loadMappedStatement(String statementId) throws Exception {
Configuration configuration = new Configuration();
configuration.setEnvironment(new Environment("test", new JdbcTransactionFactory(), new NoOpDataSource()));