Browse Source

兼容用户设置 ID 空字符串,自动填充

hubin 9 years ago
parent
commit
2cea7c0fc2

+ 1 - 1
mybatis-plus/src/main/java/com/baomidou/mybatisplus/MybatisDefaultParameterHandler.java

@@ -128,7 +128,7 @@ public class MybatisDefaultParameterHandler extends DefaultParameterHandler {
 			MetaObject metaParam = ms.getConfiguration().newMetaObject(parameterObject);
 			Object idValue = metaParam.getValue(tableInfo.getKeyProperty());
 			/* 自定义 ID */
-			if ( idValue == null ) {
+			if ( null == idValue || "".equals(idValue) ) {
 				if ( tableInfo.getIdType() == IdType.ID_WORKER ) {
 					metaParam.setValue(tableInfo.getKeyProperty(), IdWorker.getId());
 				} else if ( tableInfo.getIdType() == IdType.UUID ) {