From 7e09c8a647972fe576be613d0df527936fd86549 Mon Sep 17 00:00:00 2001 From: JiHongYuan <1206429202@qq.com> Date: Wed, 13 Oct 2021 00:50:48 +0800 Subject: [PATCH 1/4] fix discriminator use resultMap not type, use constructor NullPointerException --- src/main/java/org/apache/ibatis/mapping/ResultMap.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/apache/ibatis/mapping/ResultMap.java b/src/main/java/org/apache/ibatis/mapping/ResultMap.java index 48071c204b6..92e9a3ac088 100644 --- a/src/main/java/org/apache/ibatis/mapping/ResultMap.java +++ b/src/main/java/org/apache/ibatis/mapping/ResultMap.java @@ -122,7 +122,7 @@ public ResultMap build() { if (resultMap.idResultMappings.isEmpty()) { resultMap.idResultMappings.addAll(resultMap.resultMappings); } - if (!constructorArgNames.isEmpty()) { + if (!constructorArgNames.isEmpty() && resultMap.type != null) { final List actualArgNames = argNamesOfMatchingConstructor(constructorArgNames); if (actualArgNames == null) { throw new BuilderException("Error in result map '" + resultMap.id From 748d296a57c63af21de9cf2d2dafa6c4a8416098 Mon Sep 17 00:00:00 2001 From: JiHongYuan <1206429202@qq.com> Date: Wed, 13 Oct 2021 00:51:37 +0800 Subject: [PATCH 2/4] Update Test Cased --- src/test/java/org/apache/ibatis/builder/xsd/BlogMapper.xml | 3 +++ src/test/java/org/apache/ibatis/domain/blog/DraftPost.java | 6 ++++++ src/test/java/org/apache/ibatis/domain/blog/Post.java | 7 +++++++ 3 files changed, 16 insertions(+) diff --git a/src/test/java/org/apache/ibatis/builder/xsd/BlogMapper.xml b/src/test/java/org/apache/ibatis/builder/xsd/BlogMapper.xml index d01680da2e7..255a03536ea 100644 --- a/src/test/java/org/apache/ibatis/builder/xsd/BlogMapper.xml +++ b/src/test/java/org/apache/ibatis/builder/xsd/BlogMapper.xml @@ -83,6 +83,9 @@ + + + diff --git a/src/test/java/org/apache/ibatis/domain/blog/DraftPost.java b/src/test/java/org/apache/ibatis/domain/blog/DraftPost.java index 0ab0d7167bf..fc30d70f773 100644 --- a/src/test/java/org/apache/ibatis/domain/blog/DraftPost.java +++ b/src/test/java/org/apache/ibatis/domain/blog/DraftPost.java @@ -16,4 +16,10 @@ package org.apache.ibatis.domain.blog; public class DraftPost extends Post { + public DraftPost() { + } + + public DraftPost(int id) { + super(id); + } } diff --git a/src/test/java/org/apache/ibatis/domain/blog/Post.java b/src/test/java/org/apache/ibatis/domain/blog/Post.java index 345b43c01b6..d82238a56f6 100644 --- a/src/test/java/org/apache/ibatis/domain/blog/Post.java +++ b/src/test/java/org/apache/ibatis/domain/blog/Post.java @@ -30,6 +30,13 @@ public class Post { private List comments; private List tags; + public Post() { + } + + public Post(int id) { + this.id = id; + } + public int getId() { return id; } From cd1bb3938b61b88535a53431332a2e2b56ae64ab Mon Sep 17 00:00:00 2001 From: JiHongYuan <1206429202@qq.com> Date: Fri, 17 Dec 2021 09:52:09 +0800 Subject: [PATCH 3/4] Revert "Update Test Cased" This reverts commit 748d296a57c63af21de9cf2d2dafa6c4a8416098. --- src/test/java/org/apache/ibatis/builder/xsd/BlogMapper.xml | 3 --- src/test/java/org/apache/ibatis/domain/blog/DraftPost.java | 6 ------ src/test/java/org/apache/ibatis/domain/blog/Post.java | 7 ------- 3 files changed, 16 deletions(-) diff --git a/src/test/java/org/apache/ibatis/builder/xsd/BlogMapper.xml b/src/test/java/org/apache/ibatis/builder/xsd/BlogMapper.xml index 255a03536ea..d01680da2e7 100644 --- a/src/test/java/org/apache/ibatis/builder/xsd/BlogMapper.xml +++ b/src/test/java/org/apache/ibatis/builder/xsd/BlogMapper.xml @@ -83,9 +83,6 @@ - - - diff --git a/src/test/java/org/apache/ibatis/domain/blog/DraftPost.java b/src/test/java/org/apache/ibatis/domain/blog/DraftPost.java index fc30d70f773..0ab0d7167bf 100644 --- a/src/test/java/org/apache/ibatis/domain/blog/DraftPost.java +++ b/src/test/java/org/apache/ibatis/domain/blog/DraftPost.java @@ -16,10 +16,4 @@ package org.apache.ibatis.domain.blog; public class DraftPost extends Post { - public DraftPost() { - } - - public DraftPost(int id) { - super(id); - } } diff --git a/src/test/java/org/apache/ibatis/domain/blog/Post.java b/src/test/java/org/apache/ibatis/domain/blog/Post.java index d82238a56f6..345b43c01b6 100644 --- a/src/test/java/org/apache/ibatis/domain/blog/Post.java +++ b/src/test/java/org/apache/ibatis/domain/blog/Post.java @@ -30,13 +30,6 @@ public class Post { private List comments; private List tags; - public Post() { - } - - public Post(int id) { - this.id = id; - } - public int getId() { return id; } From defbb8e2d309b74b652b5f87336019d3e8a30e60 Mon Sep 17 00:00:00 2001 From: JiHongYuan <1206429202@qq.com> Date: Fri, 17 Dec 2021 10:00:15 +0800 Subject: [PATCH 4/4] Add Constructor Test Case --- .../org/apache/ibatis/builder/BlogMapper.xml | 45 ++++++++++++++++++- .../apache/ibatis/builder/xsd/BlogMapper.xml | 45 ++++++++++++++++++- .../apache/ibatis/domain/blog/DraftPost.java | 7 +++ .../org/apache/ibatis/domain/blog/Post.java | 7 +++ .../domain/blog/mappers/BlogMapper.java | 2 + .../apache/ibatis/session/SqlSessionTest.java | 9 ++++ 6 files changed, 113 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/apache/ibatis/builder/BlogMapper.xml b/src/test/java/org/apache/ibatis/builder/BlogMapper.xml index a83bc33dffa..56352bb21df 100644 --- a/src/test/java/org/apache/ibatis/builder/BlogMapper.xml +++ b/src/test/java/org/apache/ibatis/builder/BlogMapper.xml @@ -1,7 +1,7 @@