Skip to content

Conversation

@kazuki43zoo
Copy link
Member

I propose to support repeatable annotation on @Arg and @Result as follow:

 @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 selectAuthor(int id);

and

 @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) @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 selectAuthor(int id);

Above is equal to :

 @Results({ @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 selectAuthor(int id);
 @ConstructorArgs({ @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) }) @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 selectAuthor(int id);

By this changes, a develop can be omit the @Results and @ConstructorArgs for none-reusable result mapping.

@mybatis/committers WDYT?

@kazuki43zoo kazuki43zoo added the enhancement Improve a feature or add a new feature label Oct 27, 2019
@kazuki43zoo kazuki43zoo requested a review from harawata October 27, 2019 06:09
@kazuki43zoo kazuki43zoo self-assigned this Oct 27, 2019
Copy link
Member

@harawata harawata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thank you, @kazuki43zoo !

@kazuki43zoo kazuki43zoo added this to the 3.5.4 milestone Oct 31, 2019
@kazuki43zoo kazuki43zoo merged commit 13f8eef into mybatis:master Oct 31, 2019
@kazuki43zoo kazuki43zoo deleted the support-repeatable-annotation-on-result-and-arg branch October 31, 2019 22:29
kazuki43zoo added a commit that referenced this pull request Nov 1, 2019
pulllock pushed a commit to pulllock/mybatis-3 that referenced this pull request Oct 19, 2023
pulllock pushed a commit to pulllock/mybatis-3 that referenced this pull request Oct 19, 2023
…nnotation-on-result-and-arg Support repeatable annotation on `@Arg` and `@Result`
pulllock pushed a commit to pulllock/mybatis-3 that referenced this pull request Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Improve a feature or add a new feature

2 participants