主键生成策略(uuid)不支持的类型打印警告日志.
https://github.com/baomidou/mybatis-plus/issues/6337
This commit is contained in:
parent
6d5f2271e2
commit
d3816c3339
@ -23,6 +23,7 @@ import com.baomidou.mybatisplus.core.toolkit.ArrayUtils;
|
|||||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.GlobalConfigUtils;
|
import com.baomidou.mybatisplus.core.toolkit.GlobalConfigUtils;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||||
|
import org.apache.ibatis.logging.Log;
|
||||||
import org.apache.ibatis.mapping.BoundSql;
|
import org.apache.ibatis.mapping.BoundSql;
|
||||||
import org.apache.ibatis.mapping.MappedStatement;
|
import org.apache.ibatis.mapping.MappedStatement;
|
||||||
import org.apache.ibatis.mapping.SqlCommandType;
|
import org.apache.ibatis.mapping.SqlCommandType;
|
||||||
@ -60,10 +61,12 @@ public class MybatisParameterHandler extends DefaultParameterHandler {
|
|||||||
private final Configuration configuration;
|
private final Configuration configuration;
|
||||||
private final SqlCommandType sqlCommandType;
|
private final SqlCommandType sqlCommandType;
|
||||||
private final MappedStatement mappedStatement;
|
private final MappedStatement mappedStatement;
|
||||||
|
private final Log log;
|
||||||
|
|
||||||
public MybatisParameterHandler(MappedStatement mappedStatement, Object parameter, BoundSql boundSql) {
|
public MybatisParameterHandler(MappedStatement mappedStatement, Object parameter, BoundSql boundSql) {
|
||||||
super(mappedStatement, parameter, boundSql);
|
super(mappedStatement, parameter, boundSql);
|
||||||
this.mappedStatement = mappedStatement;
|
this.mappedStatement = mappedStatement;
|
||||||
|
this.log = mappedStatement.getStatementLog();
|
||||||
this.configuration = mappedStatement.getConfiguration();
|
this.configuration = mappedStatement.getConfiguration();
|
||||||
this.sqlCommandType = mappedStatement.getSqlCommandType();
|
this.sqlCommandType = mappedStatement.getSqlCommandType();
|
||||||
processParameter(parameter);
|
processParameter(parameter);
|
||||||
@ -123,7 +126,11 @@ public class MybatisParameterHandler extends DefaultParameterHandler {
|
|||||||
Number id = identifierGenerator.nextId(entity);
|
Number id = identifierGenerator.nextId(entity);
|
||||||
metaObject.setValue(keyProperty, OgnlOps.convertValue(id, tableInfo.getKeyType()));
|
metaObject.setValue(keyProperty, OgnlOps.convertValue(id, tableInfo.getKeyType()));
|
||||||
} else if (idType.getKey() == IdType.ASSIGN_UUID.getKey()) {
|
} else if (idType.getKey() == IdType.ASSIGN_UUID.getKey()) {
|
||||||
metaObject.setValue(keyProperty, identifierGenerator.nextUUID(entity));
|
if(String.class.equals(tableInfo.getKeyType())) {
|
||||||
|
metaObject.setValue(keyProperty, identifierGenerator.nextUUID(entity));
|
||||||
|
} else {
|
||||||
|
log.warn("The current ID generation strategy does not support: " + tableInfo.getKeyType());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user