From eabec4820a90604bce9f902cf79c5e0bdd586cb9 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Sun, 27 Oct 2019 14:56:50 +0900 Subject: [PATCH 1/2] Support repeatable annotation on `@Arg` and `@Result` --- .../org/apache/ibatis/annotations/Arg.java | 5 +- .../org/apache/ibatis/annotations/Result.java | 5 +- .../annotation/MapperAnnotationBuilder.java | 20 ++++- .../apache/ibatis/binding/BindingTest.java | 73 +++++++++++++++++++ .../ibatis/binding/BoundAuthorMapper.java | 52 ++++++++++++- .../WrongArgAndConstructorArgsMapper.java | 33 +++++++++ .../binding/WrongResultAndResultsMapper.java | 33 +++++++++ 7 files changed, 215 insertions(+), 6 deletions(-) create mode 100644 src/test/java/org/apache/ibatis/binding/WrongArgAndConstructorArgsMapper.java create mode 100644 src/test/java/org/apache/ibatis/binding/WrongResultAndResultsMapper.java diff --git a/src/main/java/org/apache/ibatis/annotations/Arg.java b/src/main/java/org/apache/ibatis/annotations/Arg.java index 66e037698bd..3aadcca8930 100644 --- a/src/main/java/org/apache/ibatis/annotations/Arg.java +++ b/src/main/java/org/apache/ibatis/annotations/Arg.java @@ -16,6 +16,8 @@ package org.apache.ibatis.annotations; import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Repeatable; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @@ -32,7 +34,8 @@ */ @Documented @Retention(RetentionPolicy.RUNTIME) -@Target({}) +@Target(ElementType.METHOD) +@Repeatable(ConstructorArgs.class) public @interface Arg { /** diff --git a/src/main/java/org/apache/ibatis/annotations/Result.java b/src/main/java/org/apache/ibatis/annotations/Result.java index f2096ccdd14..86db4a8d526 100644 --- a/src/main/java/org/apache/ibatis/annotations/Result.java +++ b/src/main/java/org/apache/ibatis/annotations/Result.java @@ -16,6 +16,8 @@ package org.apache.ibatis.annotations; import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Repeatable; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @@ -32,7 +34,8 @@ */ @Documented @Retention(RetentionPolicy.RUNTIME) -@Target({}) +@Target(ElementType.METHOD) +@Repeatable(Results.class) public @interface Result { /** * Returns whether id column or not. diff --git a/src/main/java/org/apache/ibatis/builder/annotation/MapperAnnotationBuilder.java b/src/main/java/org/apache/ibatis/builder/annotation/MapperAnnotationBuilder.java index 72051b8b7e0..1bc184f013e 100644 --- a/src/main/java/org/apache/ibatis/builder/annotation/MapperAnnotationBuilder.java +++ b/src/main/java/org/apache/ibatis/builder/annotation/MapperAnnotationBuilder.java @@ -229,10 +229,12 @@ private void parseCacheRef() { private String parseResultMap(Method method) { Class returnType = getReturnType(method); ConstructorArgs args = method.getAnnotation(ConstructorArgs.class); + Arg arg = method.getAnnotation(Arg.class); Results results = method.getAnnotation(Results.class); + Result result = method.getAnnotation(Result.class); TypeDiscriminator typeDiscriminator = method.getAnnotation(TypeDiscriminator.class); String resultMapId = generateResultMapName(method); - applyResultMap(resultMapId, returnType, argsIf(args), resultsIf(results), typeDiscriminator); + applyResultMap(resultMapId, returnType, argsIf(args, arg, method), resultsIf(results, result, method), typeDiscriminator); return resultMapId; } @@ -626,11 +628,23 @@ private String nullOrEmpty(String value) { return value == null || value.trim().length() == 0 ? null : value; } - private Result[] resultsIf(Results results) { + private Result[] resultsIf(Results results, Result result, Method method) { + if (results != null && result != null) { + throw new BuilderException("Cannot use both @Results and @Result annotations with together at '" + method + "'."); + } + if (result != null) { + return new Result[]{result}; + } return results == null ? new Result[0] : results.value(); } - private Arg[] argsIf(ConstructorArgs args) { + private Arg[] argsIf(ConstructorArgs args, Arg arg, Method method) { + if (args != null && arg != null) { + throw new BuilderException("Cannot use both @ConstructorArgs and @Arg annotations with together at '" + method + "'."); + } + if (arg != null) { + return new Arg[]{arg}; + } return args == null ? new Arg[0] : args.value(); } diff --git a/src/test/java/org/apache/ibatis/binding/BindingTest.java b/src/test/java/org/apache/ibatis/binding/BindingTest.java index 6edf63fe12f..e68ab39e276 100644 --- a/src/test/java/org/apache/ibatis/binding/BindingTest.java +++ b/src/test/java/org/apache/ibatis/binding/BindingTest.java @@ -36,6 +36,7 @@ import net.sf.cglib.proxy.Factory; import org.apache.ibatis.BaseDataTest; +import org.apache.ibatis.builder.BuilderException; import org.apache.ibatis.cursor.Cursor; import org.apache.ibatis.domain.blog.Author; import org.apache.ibatis.domain.blog.Blog; @@ -688,4 +689,76 @@ void registeredMappers() { assertTrue(mapperClasses.contains(BoundAuthorMapper.class)); } + @Test + void shouldMapPropertiesUsingRepeatableAnnotation() { + try (SqlSession session = sqlSessionFactory.openSession()) { + BoundAuthorMapper mapper = session.getMapper(BoundAuthorMapper.class); + Author author = new Author(-1, "cbegin", "******", "cbegin@nowhere.com", "N/A", Section.NEWS); + mapper.insertAuthor(author); + Author author2 = mapper.selectAuthorMapToPropertiesUsingRepeatable(author.getId()); + assertNotNull(author2); + assertEquals(author.getId(), author2.getId()); + assertEquals(author.getUsername(), author2.getUsername()); + assertEquals(author.getPassword(), author2.getPassword()); + assertEquals(author.getBio(), author2.getBio()); + assertEquals(author.getEmail(), author2.getEmail()); + session.rollback(); + } + } + + @Test + void shouldMapConstructorUsingRepeatableAnnotation() { + try (SqlSession session = sqlSessionFactory.openSession()) { + BoundAuthorMapper mapper = session.getMapper(BoundAuthorMapper.class); + Author author = new Author(-1, "cbegin", "******", "cbegin@nowhere.com", "N/A", Section.NEWS); + mapper.insertAuthor(author); + Author author2 = mapper.selectAuthorMapToConstructorUsingRepeatable(author.getId()); + assertNotNull(author2); + assertEquals(author.getId(), author2.getId()); + assertEquals(author.getUsername(), author2.getUsername()); + assertEquals(author.getPassword(), author2.getPassword()); + assertEquals(author.getBio(), author2.getBio()); + assertEquals(author.getEmail(), author2.getEmail()); + assertEquals(author.getFavouriteSection(), author2.getFavouriteSection()); + session.rollback(); + } + } + + @Test + void shouldMapUsingSingleRepeatableAnnotation() { + try (SqlSession session = sqlSessionFactory.openSession()) { + BoundAuthorMapper mapper = session.getMapper(BoundAuthorMapper.class); + Author author = new Author(-1, "cbegin", "******", "cbegin@nowhere.com", "N/A", Section.NEWS); + mapper.insertAuthor(author); + Author author2 = mapper.selectAuthorUsingSingleRepeatable(author.getId()); + assertNotNull(author2); + assertEquals(author.getId(), author2.getId()); + assertEquals(author.getUsername(), author2.getUsername()); + assertNull(author2.getPassword()); + assertNull(author2.getBio()); + assertNull(author2.getEmail()); + assertNull(author2.getFavouriteSection()); + session.rollback(); + } + } + + @Test + void shouldErrorWhenSpecifyBothArgAndConstructorArgs() { + try (SqlSession session = sqlSessionFactory.openSession()) { + BuilderException exception = Assertions.assertThrows(BuilderException.class,() + -> session.getConfiguration().addMapper(WrongArgAndConstructorArgsMapper.class)); + Assertions.assertEquals("Cannot use both @ConstructorArgs and @Arg annotations with together at 'public abstract org.apache.ibatis.domain.blog.Author org.apache.ibatis.binding.WrongArgAndConstructorArgsMapper.selectAuthor(int)'.", exception.getMessage()); + } + } + + @Test + void shouldErrorWhenSpecifyBothResultAndResults() { + try (SqlSession session = sqlSessionFactory.openSession()) { + BuilderException exception = Assertions.assertThrows(BuilderException.class,() + -> session.getConfiguration().addMapper(WrongResultAndResultsMapper.class)); + Assertions.assertEquals("Cannot use both @Results and @Result annotations with together at 'public abstract org.apache.ibatis.domain.blog.Author org.apache.ibatis.binding.WrongResultAndResultsMapper.selectAuthor(int)'.", exception.getMessage()); + } + } + } + diff --git a/src/test/java/org/apache/ibatis/binding/BoundAuthorMapper.java b/src/test/java/org/apache/ibatis/binding/BoundAuthorMapper.java index a240332f50e..0940f5a6617 100644 --- a/src/test/java/org/apache/ibatis/binding/BoundAuthorMapper.java +++ b/src/test/java/org/apache/ibatis/binding/BoundAuthorMapper.java @@ -1,5 +1,5 @@ /** - * Copyright 2009-2018 the original author or authors. + * Copyright 2009-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -68,6 +68,23 @@ public interface BoundAuthorMapper { //====================================================== + @Result(property = "id", column = "AUTHOR_ID", id = true) + @Result(property = "username", column = "AUTHOR_USERNAME") + @Result(property = "password", column = "AUTHOR_PASSWORD") + @Result(property = "email", column = "AUTHOR_EMAIL") + @Result(property = "bio", column = "AUTHOR_BIO") + @Select({ + "SELECT ", + " ID as AUTHOR_ID,", + " USERNAME as AUTHOR_USERNAME,", + " PASSWORD as AUTHOR_PASSWORD,", + " EMAIL as AUTHOR_EMAIL,", + " BIO as AUTHOR_BIO", + "FROM AUTHOR WHERE ID = #{id}"}) + Author selectAuthorMapToPropertiesUsingRepeatable(int id); + + //====================================================== + @ConstructorArgs({ @Arg(column = "AUTHOR_ID", javaType = Integer.class), @Arg(column = "AUTHOR_USERNAME", javaType = String.class), @@ -89,6 +106,39 @@ public interface BoundAuthorMapper { //====================================================== + @Arg(column = "AUTHOR_ID", javaType = Integer.class, id = true) + @Arg(column = "AUTHOR_USERNAME", javaType = String.class) + @Arg(column = "AUTHOR_PASSWORD", javaType = String.class) + @Arg(column = "AUTHOR_EMAIL", javaType = String.class) + @Arg(column = "AUTHOR_BIO", javaType = String.class) + @Arg(column = "AUTHOR_SECTION", javaType = Section.class) + @Select({ + "SELECT ", + " ID as AUTHOR_ID,", + " USERNAME as AUTHOR_USERNAME,", + " PASSWORD as AUTHOR_PASSWORD,", + " EMAIL as AUTHOR_EMAIL,", + " BIO as AUTHOR_BIO," + + " FAVOURITE_SECTION as AUTHOR_SECTION", + "FROM AUTHOR WHERE ID = #{id}"}) + Author selectAuthorMapToConstructorUsingRepeatable(int id); + + //====================================================== + + @Arg(column = "AUTHOR_ID", javaType = int.class) + @Result(property = "username", column = "AUTHOR_USERNAME") + @Select({ + "SELECT ", + " ID as AUTHOR_ID,", + " USERNAME as AUTHOR_USERNAME,", + " PASSWORD as AUTHOR_PASSWORD,", + " EMAIL as AUTHOR_EMAIL,", + " BIO as AUTHOR_BIO", + "FROM AUTHOR WHERE ID = #{id}"}) + Author selectAuthorUsingSingleRepeatable(int id); + + //====================================================== + List findThreeSpecificPosts(@Param("one") int one, RowBounds rowBounds, @Param("two") int two, diff --git a/src/test/java/org/apache/ibatis/binding/WrongArgAndConstructorArgsMapper.java b/src/test/java/org/apache/ibatis/binding/WrongArgAndConstructorArgsMapper.java new file mode 100644 index 00000000000..7bb62768287 --- /dev/null +++ b/src/test/java/org/apache/ibatis/binding/WrongArgAndConstructorArgsMapper.java @@ -0,0 +1,33 @@ +/** + * Copyright 2009-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.ibatis.binding; + +import org.apache.ibatis.annotations.Arg; +import org.apache.ibatis.annotations.ConstructorArgs; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.domain.blog.Author; + +public interface WrongArgAndConstructorArgsMapper { + + @ConstructorArgs(@Arg(column = "AUTHOR_ID", javaType = int.class)) + @Arg(column = "AUTHOR_ID", javaType = int.class) + @Select({ + "SELECT ", + " ID as AUTHOR_ID", + "FROM AUTHOR WHERE ID = #{id}"}) + Author selectAuthor(int id); + +} diff --git a/src/test/java/org/apache/ibatis/binding/WrongResultAndResultsMapper.java b/src/test/java/org/apache/ibatis/binding/WrongResultAndResultsMapper.java new file mode 100644 index 00000000000..93f02bb5368 --- /dev/null +++ b/src/test/java/org/apache/ibatis/binding/WrongResultAndResultsMapper.java @@ -0,0 +1,33 @@ +/** + * Copyright 2009-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.ibatis.binding; + +import org.apache.ibatis.annotations.Result; +import org.apache.ibatis.annotations.Results; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.domain.blog.Author; + +public interface WrongResultAndResultsMapper { + + @Results(@Result(property = "id", column = "AUTHOR_ID")) + @Result(property = "id", column = "AUTHOR_ID") + @Select({ + "SELECT ", + " ID as AUTHOR_ID", + "FROM AUTHOR WHERE ID = #{id}"}) + Author selectAuthor(int id); + +} From d6d56183ac57eb90de39241d13f00658f2bd39ff Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Fri, 1 Nov 2019 03:06:29 +0900 Subject: [PATCH 2/2] Change to use the Methd#getAnnotationsByType for getting arrays of @Result and @Arg For gh-1698 --- .../annotation/MapperAnnotationBuilder.java | 29 ++-------------- .../apache/ibatis/binding/BindingTest.java | 34 ++++++++++++++----- .../ibatis/binding/BoundAuthorMapper.java | 34 +++++++++++++++++++ .../WrongArgAndConstructorArgsMapper.java | 33 ------------------ .../binding/WrongResultAndResultsMapper.java | 33 ------------------ 5 files changed, 63 insertions(+), 100 deletions(-) delete mode 100644 src/test/java/org/apache/ibatis/binding/WrongArgAndConstructorArgsMapper.java delete mode 100644 src/test/java/org/apache/ibatis/binding/WrongResultAndResultsMapper.java diff --git a/src/main/java/org/apache/ibatis/builder/annotation/MapperAnnotationBuilder.java b/src/main/java/org/apache/ibatis/builder/annotation/MapperAnnotationBuilder.java index 1bc184f013e..20b14e69557 100644 --- a/src/main/java/org/apache/ibatis/builder/annotation/MapperAnnotationBuilder.java +++ b/src/main/java/org/apache/ibatis/builder/annotation/MapperAnnotationBuilder.java @@ -39,7 +39,6 @@ import org.apache.ibatis.annotations.CacheNamespace; import org.apache.ibatis.annotations.CacheNamespaceRef; import org.apache.ibatis.annotations.Case; -import org.apache.ibatis.annotations.ConstructorArgs; import org.apache.ibatis.annotations.Delete; import org.apache.ibatis.annotations.DeleteProvider; import org.apache.ibatis.annotations.Insert; @@ -228,13 +227,11 @@ private void parseCacheRef() { private String parseResultMap(Method method) { Class returnType = getReturnType(method); - ConstructorArgs args = method.getAnnotation(ConstructorArgs.class); - Arg arg = method.getAnnotation(Arg.class); - Results results = method.getAnnotation(Results.class); - Result result = method.getAnnotation(Result.class); + Arg[] args = method.getAnnotationsByType(Arg.class); + Result[] results = method.getAnnotationsByType(Result.class); TypeDiscriminator typeDiscriminator = method.getAnnotation(TypeDiscriminator.class); String resultMapId = generateResultMapName(method); - applyResultMap(resultMapId, returnType, argsIf(args, arg, method), resultsIf(results, result, method), typeDiscriminator); + applyResultMap(resultMapId, returnType, args, results, typeDiscriminator); return resultMapId; } @@ -628,26 +625,6 @@ private String nullOrEmpty(String value) { return value == null || value.trim().length() == 0 ? null : value; } - private Result[] resultsIf(Results results, Result result, Method method) { - if (results != null && result != null) { - throw new BuilderException("Cannot use both @Results and @Result annotations with together at '" + method + "'."); - } - if (result != null) { - return new Result[]{result}; - } - return results == null ? new Result[0] : results.value(); - } - - private Arg[] argsIf(ConstructorArgs args, Arg arg, Method method) { - if (args != null && arg != null) { - throw new BuilderException("Cannot use both @ConstructorArgs and @Arg annotations with together at '" + method + "'."); - } - if (arg != null) { - return new Arg[]{arg}; - } - return args == null ? new Arg[0] : args.value(); - } - private KeyGenerator handleSelectKeyAnnotation(SelectKey selectKeyAnnotation, String baseStatementId, Class parameterTypeClass, LanguageDriver languageDriver) { String id = baseStatementId + SelectKeyGenerator.SELECT_KEY_SUFFIX; Class resultTypeClass = selectKeyAnnotation.resultType(); diff --git a/src/test/java/org/apache/ibatis/binding/BindingTest.java b/src/test/java/org/apache/ibatis/binding/BindingTest.java index e68ab39e276..b1dfb91dcaf 100644 --- a/src/test/java/org/apache/ibatis/binding/BindingTest.java +++ b/src/test/java/org/apache/ibatis/binding/BindingTest.java @@ -743,20 +743,38 @@ void shouldMapUsingSingleRepeatableAnnotation() { } @Test - void shouldErrorWhenSpecifyBothArgAndConstructorArgs() { + void shouldMapWhenSpecifyBothArgAndConstructorArgs() { try (SqlSession session = sqlSessionFactory.openSession()) { - BuilderException exception = Assertions.assertThrows(BuilderException.class,() - -> session.getConfiguration().addMapper(WrongArgAndConstructorArgsMapper.class)); - Assertions.assertEquals("Cannot use both @ConstructorArgs and @Arg annotations with together at 'public abstract org.apache.ibatis.domain.blog.Author org.apache.ibatis.binding.WrongArgAndConstructorArgsMapper.selectAuthor(int)'.", exception.getMessage()); + BoundAuthorMapper mapper = session.getMapper(BoundAuthorMapper.class); + Author author = new Author(-1, "cbegin", "******", "cbegin@nowhere.com", "N/A", Section.NEWS); + mapper.insertAuthor(author); + Author author2 = mapper.selectAuthorUsingBothArgAndConstructorArgs(author.getId()); + assertNotNull(author2); + assertEquals(author.getId(), author2.getId()); + assertEquals(author.getUsername(), author2.getUsername()); + assertEquals(author.getPassword(), author2.getPassword()); + assertEquals(author.getBio(), author2.getBio()); + assertEquals(author.getEmail(), author2.getEmail()); + assertEquals(author.getFavouriteSection(), author2.getFavouriteSection()); + session.rollback(); } } @Test - void shouldErrorWhenSpecifyBothResultAndResults() { + void shouldMapWhenSpecifyBothResultAndResults() { try (SqlSession session = sqlSessionFactory.openSession()) { - BuilderException exception = Assertions.assertThrows(BuilderException.class,() - -> session.getConfiguration().addMapper(WrongResultAndResultsMapper.class)); - Assertions.assertEquals("Cannot use both @Results and @Result annotations with together at 'public abstract org.apache.ibatis.domain.blog.Author org.apache.ibatis.binding.WrongResultAndResultsMapper.selectAuthor(int)'.", exception.getMessage()); + BoundAuthorMapper mapper = session.getMapper(BoundAuthorMapper.class); + Author author = new Author(-1, "cbegin", "******", "cbegin@nowhere.com", "N/A", Section.NEWS); + mapper.insertAuthor(author); + Author author2 = mapper.selectAuthorUsingBothResultAndResults(author.getId()); + assertNotNull(author2); + assertEquals(author.getId(), author2.getId()); + assertEquals(author.getUsername(), author2.getUsername()); + assertNull(author2.getPassword()); + assertNull(author2.getBio()); + assertNull(author2.getEmail()); + assertNull(author2.getFavouriteSection()); + session.rollback(); } } diff --git a/src/test/java/org/apache/ibatis/binding/BoundAuthorMapper.java b/src/test/java/org/apache/ibatis/binding/BoundAuthorMapper.java index 0940f5a6617..d47954feb3f 100644 --- a/src/test/java/org/apache/ibatis/binding/BoundAuthorMapper.java +++ b/src/test/java/org/apache/ibatis/binding/BoundAuthorMapper.java @@ -139,6 +139,40 @@ public interface BoundAuthorMapper { //====================================================== + @ConstructorArgs({ + @Arg(column = "AUTHOR_ID", javaType = Integer.class), + @Arg(column = "AUTHOR_USERNAME", javaType = String.class), + @Arg(column = "AUTHOR_PASSWORD", javaType = String.class), + @Arg(column = "AUTHOR_EMAIL", javaType = String.class), + @Arg(column = "AUTHOR_BIO", javaType = String.class) + }) + @Arg(column = "AUTHOR_SECTION", javaType = Section.class) + @Select({ + "SELECT ", + " ID as AUTHOR_ID,", + " USERNAME as AUTHOR_USERNAME,", + " PASSWORD as AUTHOR_PASSWORD,", + " EMAIL as AUTHOR_EMAIL,", + " BIO as AUTHOR_BIO," + + " FAVOURITE_SECTION as AUTHOR_SECTION", + "FROM AUTHOR WHERE ID = #{id}"}) + Author selectAuthorUsingBothArgAndConstructorArgs(int id); + + //====================================================== + + @Results( + @Result(property = "id", column = "AUTHOR_ID") + ) + @Result(property = "username", column = "AUTHOR_USERNAME") + @Select({ + "SELECT ", + " ID as AUTHOR_ID,", + " USERNAME as AUTHOR_USERNAME", + "FROM AUTHOR WHERE ID = #{id}"}) + Author selectAuthorUsingBothResultAndResults(int id); + + //====================================================== + List findThreeSpecificPosts(@Param("one") int one, RowBounds rowBounds, @Param("two") int two, diff --git a/src/test/java/org/apache/ibatis/binding/WrongArgAndConstructorArgsMapper.java b/src/test/java/org/apache/ibatis/binding/WrongArgAndConstructorArgsMapper.java deleted file mode 100644 index 7bb62768287..00000000000 --- a/src/test/java/org/apache/ibatis/binding/WrongArgAndConstructorArgsMapper.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright 2009-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.ibatis.binding; - -import org.apache.ibatis.annotations.Arg; -import org.apache.ibatis.annotations.ConstructorArgs; -import org.apache.ibatis.annotations.Select; -import org.apache.ibatis.domain.blog.Author; - -public interface WrongArgAndConstructorArgsMapper { - - @ConstructorArgs(@Arg(column = "AUTHOR_ID", javaType = int.class)) - @Arg(column = "AUTHOR_ID", javaType = int.class) - @Select({ - "SELECT ", - " ID as AUTHOR_ID", - "FROM AUTHOR WHERE ID = #{id}"}) - Author selectAuthor(int id); - -} diff --git a/src/test/java/org/apache/ibatis/binding/WrongResultAndResultsMapper.java b/src/test/java/org/apache/ibatis/binding/WrongResultAndResultsMapper.java deleted file mode 100644 index 93f02bb5368..00000000000 --- a/src/test/java/org/apache/ibatis/binding/WrongResultAndResultsMapper.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright 2009-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.ibatis.binding; - -import org.apache.ibatis.annotations.Result; -import org.apache.ibatis.annotations.Results; -import org.apache.ibatis.annotations.Select; -import org.apache.ibatis.domain.blog.Author; - -public interface WrongResultAndResultsMapper { - - @Results(@Result(property = "id", column = "AUTHOR_ID")) - @Result(property = "id", column = "AUTHOR_ID") - @Select({ - "SELECT ", - " ID as AUTHOR_ID", - "FROM AUTHOR WHERE ID = #{id}"}) - Author selectAuthor(int id); - -}