|
|
|
|
@ -43,6 +43,7 @@ import org.springframework.data.relational.core.dialect.SqlServerDialect;
@@ -43,6 +43,7 @@ import org.springframework.data.relational.core.dialect.SqlServerDialect;
|
|
|
|
|
import org.springframework.data.relational.core.mapping.AggregatePath; |
|
|
|
|
import org.springframework.data.relational.core.mapping.Column; |
|
|
|
|
import org.springframework.data.relational.core.mapping.DefaultNamingStrategy; |
|
|
|
|
import org.springframework.data.relational.core.mapping.MappedCollection; |
|
|
|
|
import org.springframework.data.relational.core.mapping.RelationalMappingContext; |
|
|
|
|
import org.springframework.data.relational.core.mapping.RelationalPersistentEntity; |
|
|
|
|
import org.springframework.data.relational.core.mapping.RelationalPersistentProperty; |
|
|
|
|
@ -388,7 +389,8 @@ class SqlGeneratorUnitTests {
@@ -388,7 +389,8 @@ class SqlGeneratorUnitTests {
|
|
|
|
|
void findAllByPropertyWithKey() { |
|
|
|
|
|
|
|
|
|
// this would get called when ListParent is th element type of a Map
|
|
|
|
|
String sql = sqlGenerator.getFindAllByProperty(BACKREF, new AggregatePath.ColumnInfo(unquoted("key-column"),unquoted("key-column")), false); |
|
|
|
|
String sql = sqlGenerator.getFindAllByProperty(BACKREF, |
|
|
|
|
new AggregatePath.ColumnInfo(unquoted("key-column"), unquoted("key-column")), false); |
|
|
|
|
|
|
|
|
|
assertThat(sql).isEqualTo("SELECT dummy_entity.id1 AS id1, dummy_entity.x_name AS x_name, " //
|
|
|
|
|
+ "dummy_entity.x_other AS x_other, " //
|
|
|
|
|
@ -926,6 +928,16 @@ class SqlGeneratorUnitTests {
@@ -926,6 +928,16 @@ class SqlGeneratorUnitTests {
|
|
|
|
|
"WHERE referenced_entity.parentId"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test // GH-1865
|
|
|
|
|
void mappingMapKeyToChildShouldNotResultInDuplicateColumn() { |
|
|
|
|
|
|
|
|
|
SqlGenerator sqlGenerator = createSqlGenerator(Child.class); |
|
|
|
|
String sql = sqlGenerator.getFindAllByProperty(Identifier.of(unquoted("parent"), 23, Parent.class), |
|
|
|
|
context.getAggregatePath(getPath("children", Parent.class)).getTableInfo().qualifierColumnInfo(), false); |
|
|
|
|
|
|
|
|
|
assertThat(sql).containsOnlyOnce("child.NICK_NAME AS NICK_NAME"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Nullable |
|
|
|
|
private SqlIdentifier getAlias(Object maybeAliased) { |
|
|
|
|
|
|
|
|
|
@ -1117,4 +1129,10 @@ class SqlGeneratorUnitTests {
@@ -1117,4 +1129,10 @@ class SqlGeneratorUnitTests {
|
|
|
|
|
@Id Long id; |
|
|
|
|
IdNoIdChain idNoIdChain; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
record Parent(@Id Long id, String name, @MappedCollection(keyColumn = "NICK_NAME") Map<String, Child> children) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
record Child(@Column("NICK_NAME") String nickName, String name) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|