mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 00:58:24 +08:00
fix: fixed and close https://gitee.com/mybatis-flex/mybatis-flex/issues/ID64KB
This commit is contained in:
parent
4d82711fa8
commit
10e595a628
@ -42,8 +42,9 @@ public class RowKeyGenerator implements KeyGenerator, IMultiKeyGenerator {
|
|||||||
private static final KeyGenerator[] NO_KEY_GENERATORS = new KeyGenerator[0];
|
private static final KeyGenerator[] NO_KEY_GENERATORS = new KeyGenerator[0];
|
||||||
|
|
||||||
private final MappedStatement ms;
|
private final MappedStatement ms;
|
||||||
private KeyGenerator[] keyGenerators;
|
|
||||||
private Set<String> autoKeyGeneratorNames;
|
private Set<String> autoKeyGeneratorNames;
|
||||||
|
private KeyGenerator[] keyGenerators;
|
||||||
|
|
||||||
|
|
||||||
public RowKeyGenerator(MappedStatement methodMappedStatement) {
|
public RowKeyGenerator(MappedStatement methodMappedStatement) {
|
||||||
this.ms = methodMappedStatement;
|
this.ms = methodMappedStatement;
|
||||||
@ -52,6 +53,8 @@ public class RowKeyGenerator implements KeyGenerator, IMultiKeyGenerator {
|
|||||||
@Override
|
@Override
|
||||||
public void processBefore(Executor executor, MappedStatement ms, Statement stmt, Object parameter) {
|
public void processBefore(Executor executor, MappedStatement ms, Statement stmt, Object parameter) {
|
||||||
Row row = (Row) ((Map<?, ?>) parameter).get(FlexConsts.ROW);
|
Row row = (Row) ((Map<?, ?>) parameter).get(FlexConsts.ROW);
|
||||||
|
// 重置 autoKeyGeneratorNames fix https://gitee.com/mybatis-flex/mybatis-flex/issues/ID64KB
|
||||||
|
autoKeyGeneratorNames = null;
|
||||||
keyGenerators = buildRowKeyGenerators(RowCPI.obtainsPrimaryKeys(row));
|
keyGenerators = buildRowKeyGenerators(RowCPI.obtainsPrimaryKeys(row));
|
||||||
for (KeyGenerator keyGenerator : keyGenerators) {
|
for (KeyGenerator keyGenerator : keyGenerators) {
|
||||||
keyGenerator.processBefore(executor, ms, stmt, parameter);
|
keyGenerator.processBefore(executor, ms, stmt, parameter);
|
||||||
@ -89,7 +92,7 @@ public class RowKeyGenerator implements KeyGenerator, IMultiKeyGenerator {
|
|||||||
String keyColumn = rowKey.getKeyColumn();
|
String keyColumn = rowKey.getKeyColumn();
|
||||||
if (rowKey.getKeyType() == KeyType.Auto) {
|
if (rowKey.getKeyType() == KeyType.Auto) {
|
||||||
if (autoKeyGeneratorNames == null) {
|
if (autoKeyGeneratorNames == null) {
|
||||||
autoKeyGeneratorNames = new HashSet<>();
|
autoKeyGeneratorNames = new LinkedHashSet<>();
|
||||||
}
|
}
|
||||||
autoKeyGeneratorNames.add(keyColumn);
|
autoKeyGeneratorNames.add(keyColumn);
|
||||||
return new RowJdbc3KeyGenerator(keyColumn);
|
return new RowJdbc3KeyGenerator(keyColumn);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user