spring-projects / spring-projects/spring-data-relational

Make sure referenced immutable Entities get updated in collections even if the immutable parent doesn't have an explicit id [DATAJDBC-433]

Đang mở
#653 0 bình luận 0 reaction 1 người được giao Xem trên GitHub

@schauder đang làm issue này rồi.

Từ ngày 31/12/2020.

type: bug
Ngôn ngữ chính
Java
Star
827
Fork
394
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Jens Schauder opened DATAJDBC-433 and commented

If an entity A contains a collection List<C> with A and C both being immutable, A needs to get updated even though it might not have an id if C has or any of the classes it references directly or indirectly.

This was ensured by DATAJDBC-291 by the test below but it is not entirely sure it is still handled properly by the variant about to get merged.

	@Test 
	public void updatingCollectionInEntityWithoutId() {

		CollectionOwner owner = new CollectionOwner(null, "owner", singletonList(new IdLessIntermediate("intermediate", singletonList(new Element(null, "Lovecraft")))));
		CollectionOwner saved = template.save(owner);

		Long id = saved.id;
		assertThat(id).isNotNull();

		Element savedLovecraft = saved.list.get(0).list.get(0);
		assertThat(savedLovecraft.id).isNotNull();

		CollectionOwner changedOwner = new CollectionOwner(id, "owner", singletonList(new IdLessIntermediate("intermediate", asList(savedLovecraft, new Element(null, "Sakurai")))));

		CollectionOwner savedAgain = template.save(changedOwner);

		SoftAssertions softly = new SoftAssertions();

		softly.assertThat(savedAgain.id).isEqualTo(id);
		softly.assertThat(savedAgain.list.get(0).list.get(0)).isEqualTo(savedLovecraft);
		softly.assertThat(savedAgain.list.get(0).list.get(1).id).describedAs("Element has id set and that element is part of the aggregate").isNotNull();

		softly.assertAll();
	}

Issue Links:

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.