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]

Abierto
#653 0 comentarios 0 reacciones 1 asignado Ver en GitHub

@schauder ya está trabajando en esto.

Desde el 31/12/2020.

type: bug
Lenguaje dominante
Java
Estrellas
827
Forks
394
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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:

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.