|
30 | 30 | import java.time.ZonedDateTime;
|
31 | 31 | import java.util.Date;
|
32 | 32 | import java.util.List;
|
| 33 | +import java.util.Map; |
33 | 34 | import java.util.UUID;
|
34 | 35 |
|
35 | 36 | import org.assertj.core.api.SoftAssertions;
|
|
39 | 40 | import org.springframework.data.jdbc.core.mapping.JdbcMappingContext;
|
40 | 41 | import org.springframework.data.jdbc.core.mapping.JdbcValue;
|
41 | 42 | import org.springframework.data.jdbc.support.JdbcUtil;
|
| 43 | +import org.springframework.data.relational.core.mapping.MappedCollection; |
42 | 44 | import org.springframework.data.relational.core.mapping.RelationalPersistentEntity;
|
43 | 45 | import org.springframework.data.relational.core.mapping.RelationalPersistentProperty;
|
| 46 | +import org.springframework.data.relational.domain.RowDocument; |
44 | 47 | import org.springframework.data.util.TypeInformation;
|
45 | 48 |
|
46 | 49 | /**
|
@@ -139,6 +142,17 @@ void conversionOfPrimitiveArrays() {
|
139 | 142 | assertThat(typeFactory.arraySource).containsExactly(1, 2, 3, 4, 5);
|
140 | 143 | }
|
141 | 144 |
|
| 145 | + @Test // GH-1684 |
| 146 | + void accessesCorrectValuesForOneToOneRelationshipWithIdenticallyNamedIdProperties() { |
| 147 | + |
| 148 | + RowDocument rowdocument = new RowDocument(Map.of("ID", "one", "REFERENCED_ID", 23)); |
| 149 | + |
| 150 | + WithOneToOne result = converter.readAndResolve(WithOneToOne.class, rowdocument); |
| 151 | + |
| 152 | + assertThat(result).isEqualTo(new WithOneToOne("one", new Referenced(23L))); |
| 153 | + } |
| 154 | + |
| 155 | + |
142 | 156 | private void checkConversionToTimestampAndBack(SoftAssertions softly, RelationalPersistentEntity<?> persistentEntity,
|
143 | 157 | String propertyName, Object value) {
|
144 | 158 |
|
@@ -284,4 +298,10 @@ public Array createArray(Object[] value) {
|
284 | 298 | return mock(Array.class);
|
285 | 299 | }
|
286 | 300 | }
|
| 301 | + |
| 302 | + record WithOneToOne(@Id String id,@MappedCollection(idColumn = "renamed") Referenced referenced){} |
| 303 | + |
| 304 | + record Referenced(@Id Long id) { |
| 305 | + } |
| 306 | + |
287 | 307 | }
|
0 commit comments