소스 검색

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

hubin 9 년 전
부모
커밋
2cea7c0fc2
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      mybatis-plus/src/main/java/com/baomidou/mybatisplus/MybatisDefaultParameterHandler.java

+ 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 ) {