I think there is a problem with @Version-Fields in immutable entities.
I found the test org.springframework.data.jdbc.core.JdbcAggregateTemplateIntegrationTests#saveAndUpdateAggregateWithImmutableVersion. This test is green on my machine.
I extended the test: the return value of template.save(reloadedAggregate) does not hold the incremented version number (problem occurs only at the second call!).
Please have a look at the following adjusted test:
@Test// DATAJDBC-219 Test that immutable version attribute works as expected.publicvoidsaveAndUpdateAggregateWithImmutableVersion() {
AggregateWithImmutableVersionaggregate = newAggregateWithImmutableVersion(null, null);
aggregate = template.save(aggregate);
assertThat(aggregate.version).isEqualTo(1L); // worksLongid = aggregate.getId();
AggregateWithImmutableVersionreloadedAggregate = template.findById(id, aggregate.getClass());
assertThat(reloadedAggregate.getVersion()).describedAs("version field should initially have the value 1")
.isEqualTo(1L);
AggregateWithImmutableVersionsaved = template.save(reloadedAggregate);
AggregateWithImmutableVersionupdatedAggregate = template.findById(id, aggregate.getClass());
assertThat(saved.version)
.describedAs("returned by save(): "+ saved + " vs. returned by findById(): " + updatedAggregate)
.isEqualTo(updatedAggregate.version); // fails// [..]
}
Clemens Hahn opened DATAJDBC-481 and commented
I think there is a problem with
@Version
-Fields in immutable entities.I found the test
org.springframework.data.jdbc.core.JdbcAggregateTemplateIntegrationTests#saveAndUpdateAggregateWithImmutableVersion
. This test is green on my machine.I extended the test: the return value of
template.save(reloadedAggregate)
does not hold the incremented version number (problem occurs only at the second call!).Please have a look at the following adjusted test:
This adjusted test fails with
I hope I did not make a mistake and that the current bahavior is not the expected one.
I attached a Patch-File with this adjusted test.
Attachments:
Referenced from: commits d77e9cd, 2f9d4b2
The text was updated successfully, but these errors were encountered: