|
24 | 24 | import org.junit.jupiter.api.Test;
|
25 | 25 | import org.springframework.data.annotation.Id;
|
26 | 26 | import org.springframework.data.jdbc.core.PersistentPropertyPathTestUtils;
|
| 27 | +import org.springframework.data.jdbc.core.mapping.AggregateReference; |
27 | 28 | import org.springframework.data.jdbc.core.mapping.JdbcMappingContext;
|
28 | 29 | import org.springframework.data.relational.core.mapping.Column;
|
29 | 30 | import org.springframework.data.relational.core.mapping.Embedded;
|
30 | 31 | import org.springframework.data.relational.core.mapping.Embedded.OnEmpty;
|
31 | 32 | import org.springframework.data.relational.core.mapping.RelationalMappingContext;
|
32 | 33 | import org.springframework.data.relational.core.mapping.RelationalPersistentEntity;
|
| 34 | +import org.springframework.data.relational.core.mapping.Table; |
33 | 35 | import org.springframework.data.relational.core.sql.Aliased;
|
34 | 36 | import org.springframework.data.relational.core.sql.SqlIdentifier;
|
35 | 37 | import org.springframework.lang.Nullable;
|
|
38 | 40 | * Unit tests for the {@link SqlGenerator} in a context of the {@link Embedded} annotation.
|
39 | 41 | *
|
40 | 42 | * @author Bastian Wilhelm
|
| 43 | + * @author Mark Paluch |
41 | 44 | */
|
42 | 45 | public class SqlGeneratorEmbeddedUnitTests {
|
43 | 46 |
|
@@ -213,6 +216,12 @@ public void columnForEmbeddedProperty() {
|
213 | 216 | SqlIdentifier.unquoted("test"));
|
214 | 217 | }
|
215 | 218 |
|
| 219 | + @Test // GH-1695 |
| 220 | + public void columnForEmbeddedPropertyWithPrefix() { |
| 221 | + assertThat(generatedColumn("nested.childId", WithEmbeddedAndAggregateReference.class)) |
| 222 | + .hasToString("a.nested_child_id AS nested_child_id"); |
| 223 | + } |
| 224 | + |
216 | 225 | @Test // DATAJDBC-340
|
217 | 226 | public void noColumnForEmbedded() {
|
218 | 227 |
|
@@ -352,4 +361,16 @@ static class OtherEntity {
|
352 | 361 | String value;
|
353 | 362 | }
|
354 | 363 |
|
| 364 | + @Table("a") |
| 365 | + record WithEmbeddedAndAggregateReference(@Id long id, |
| 366 | + @Embedded.Nullable(prefix = "nested_") WithAggregateReference nested) { |
| 367 | + } |
| 368 | + |
| 369 | + record WithAggregateReference(AggregateReference<Child, Long> childId) { |
| 370 | + } |
| 371 | + |
| 372 | + record Child(@Id long id) { |
| 373 | + |
| 374 | + } |
| 375 | + |
355 | 376 | }
|
0 commit comments