From e2c60caab32e51868766541e758e8defd792f36e Mon Sep 17 00:00:00 2001 From: mhyeon-lee Date: Sun, 24 Jan 2021 17:24:23 +0900 Subject: [PATCH] Fix @SqlTableAlias alias name apply to column alias (cherry picked from commit 4f097f666e87c9c07de967976f6cd19b06036a6d) --- .../data/jdbc/plus/sql/guide/board/Board.java | 3 + .../jdbc/plus/sql/guide/board/PostDto.java | 2 + .../plus/sql/guide/board/sql/BoardSql.groovy | 4 +- .../data/jdbc/plus/sql/guide/board/Board.java | 3 + .../jdbc/plus/sql/guide/board/PostDto.java | 3 + .../jdbc/plus/sql/guide/board/sql/BoardSql.kt | 4 +- .../data/jdbc/plus/sql/guide/board/Board.kt | 2 + .../data/jdbc/plus/sql/guide/board/PostDto.kt | 2 + .../jdbc/plus/sql/guide/board/sql/BoardSql.kt | 4 +- .../convert/AggregateResultJdbcConverter.java | 11 ++- ...dbcBackReferencePropertyValueProvider.java | 6 +- .../convert/JdbcPropertyValueProvider.java | 3 +- .../plus/sql/convert/PropertyPathUtils.java | 96 +++++++++++++++++++ .../jdbc/plus/sql/convert/SqlContext.java | 65 ++----------- .../plus/sql/convert/SqlProviderTest.java | 73 +++++++++----- 15 files changed, 186 insertions(+), 95 deletions(-) create mode 100644 spring-data-jdbc-plus-sql/src/main/java/com/navercorp/spring/data/jdbc/plus/sql/convert/PropertyPathUtils.java diff --git a/guide-projects/plus-sql-java-groovy-guide/src/main/java/com/navercorp/spring/data/jdbc/plus/sql/guide/board/Board.java b/guide-projects/plus-sql-java-groovy-guide/src/main/java/com/navercorp/spring/data/jdbc/plus/sql/guide/board/Board.java index 363155be..92a675cb 100644 --- a/guide-projects/plus-sql-java-groovy-guide/src/main/java/com/navercorp/spring/data/jdbc/plus/sql/guide/board/Board.java +++ b/guide-projects/plus-sql-java-groovy-guide/src/main/java/com/navercorp/spring/data/jdbc/plus/sql/guide/board/Board.java @@ -37,6 +37,8 @@ import lombok.Value; import lombok.With; +import com.navercorp.spring.data.jdbc.plus.sql.annotation.SqlTableAlias; + /** * @author Myeonghyeon Lee */ @@ -57,6 +59,7 @@ public class Board { @Builder.Default private List posts = new ArrayList<>(); + @SqlTableAlias("b_audit") @Column("board_id") private Audit audit; diff --git a/guide-projects/plus-sql-java-groovy-guide/src/main/java/com/navercorp/spring/data/jdbc/plus/sql/guide/board/PostDto.java b/guide-projects/plus-sql-java-groovy-guide/src/main/java/com/navercorp/spring/data/jdbc/plus/sql/guide/board/PostDto.java index 936efe81..0ee4c48d 100644 --- a/guide-projects/plus-sql-java-groovy-guide/src/main/java/com/navercorp/spring/data/jdbc/plus/sql/guide/board/PostDto.java +++ b/guide-projects/plus-sql-java-groovy-guide/src/main/java/com/navercorp/spring/data/jdbc/plus/sql/guide/board/PostDto.java @@ -28,6 +28,7 @@ import lombok.Builder; import lombok.Value; +import com.navercorp.spring.data.jdbc.plus.sql.annotation.SqlTableAlias; import com.navercorp.spring.data.jdbc.plus.sql.guide.board.Board.Label; import com.navercorp.spring.data.jdbc.plus.sql.guide.board.Board.Post; @@ -44,6 +45,7 @@ public class PostDto { @Column Post post; + @SqlTableAlias("p_labels") @MappedCollection(idColumn = "board_id") Set