|
39 | 39 | import org.springframework.test.context.junit4.rules.SpringMethodRule;
|
40 | 40 | import org.springframework.transaction.annotation.Transactional;
|
41 | 41 |
|
| 42 | +import java.util.ArrayList; |
| 43 | +import java.util.List; |
| 44 | + |
42 | 45 | /**
|
43 | 46 | * Integration tests for {@link JdbcAggregateTemplate}.
|
44 | 47 | *
|
@@ -217,7 +220,7 @@ public void oneToOneChildWithoutId() {
|
217 | 220 | OneToOneParent parent = new OneToOneParent();
|
218 | 221 |
|
219 | 222 | parent.content = "parent content";
|
220 |
| - parent.child = new OneToOneChildNoId(); |
| 223 | + parent.child = new ChildNoId(); |
221 | 224 | parent.child.content = "child content";
|
222 | 225 |
|
223 | 226 | template.save(parent);
|
@@ -248,7 +251,7 @@ public void oneToOneNullAttributes() {
|
248 | 251 | OneToOneParent parent = new OneToOneParent();
|
249 | 252 |
|
250 | 253 | parent.content = "parent content";
|
251 |
| - parent.child = new OneToOneChildNoId(); |
| 254 | + parent.child = new ChildNoId(); |
252 | 255 |
|
253 | 256 | template.save(parent);
|
254 | 257 |
|
@@ -289,6 +292,23 @@ public void saveAndLoadAnEntityWithSecondaryReferenceNotNull() {
|
289 | 292 |
|
290 | 293 | softly.assertAll();
|
291 | 294 | }
|
| 295 | + @Test // DATAJDBC-276 |
| 296 | + public void saveAndLoadAnEntityWithListOfElementsWithoutId() { |
| 297 | + |
| 298 | + ListParent entity = new ListParent(); |
| 299 | + entity.name = "name"; |
| 300 | + |
| 301 | + ElementNoId element = new ElementNoId(); |
| 302 | + element.content = "content"; |
| 303 | + |
| 304 | + entity.content.add(element); |
| 305 | + |
| 306 | + template.save(entity); |
| 307 | + |
| 308 | + ListParent reloaded = template.findById(entity.id, ListParent.class); |
| 309 | + |
| 310 | + assertThat(reloaded.content).extracting(e -> e.content).containsExactly("content"); |
| 311 | + } |
292 | 312 |
|
293 | 313 | private static LegoSet createLegoSet() {
|
294 | 314 |
|
@@ -326,13 +346,25 @@ static class OneToOneParent {
|
326 | 346 | @Id private Long id;
|
327 | 347 | private String content;
|
328 | 348 |
|
329 |
| - private OneToOneChildNoId child; |
| 349 | + private ChildNoId child; |
330 | 350 | }
|
331 | 351 |
|
332 |
| - static class OneToOneChildNoId { |
| 352 | + static class ChildNoId { |
333 | 353 | private String content;
|
334 | 354 | }
|
335 | 355 |
|
| 356 | + static class ListParent { |
| 357 | + |
| 358 | + @Id private Long id; |
| 359 | + String name; |
| 360 | + List<ElementNoId> content = new ArrayList<>(); |
| 361 | + } |
| 362 | + |
| 363 | + static class ElementNoId { |
| 364 | + private String content; |
| 365 | + } |
| 366 | + |
| 367 | + |
336 | 368 | @Configuration
|
337 | 369 | @Import(TestConfiguration.class)
|
338 | 370 | static class Config {
|
|
0 commit comments