Skip to content

Commit 07b85ef

Browse files
committed
Removing the @id from the MappedCollection sets the value directly into the database and does not make use of the serial
1 parent 56c4f62 commit 07b85ef

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

spring-data-jdbc/src/test/java/org/springframework/data/jdbc/repository/JdbcRepositoryOneToOneCollectionIntegrationTests.java

+14-2
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,19 @@ public void saveAndLoadAnEntity() {
6969
});
7070
}
7171

72+
@Test // GH-1684
73+
public void saveAndLoadAnEntities() {
74+
75+
DummyEntity entity = repository.save(createDummyEntity());
76+
DummyEntity entity2 = repository.save(createDummyEntity());
77+
78+
assertThat(repository.findById(entity.getId())).hasValueSatisfying(it -> {
79+
assertThat(it.getId()).isEqualTo(entity.getId());
80+
assertThat(it.getTest()).isEqualTo(entity.getTest());
81+
assertThat(it.getDummyEntity2().getId()).isEqualTo(entity.getDummyEntity2().getId());
82+
});
83+
}
84+
7285
private static DummyEntity createDummyEntity() {
7386
DummyEntity entity = new DummyEntity();
7487
entity.setTest("test");
@@ -126,8 +139,7 @@ public void setTest(String test) {
126139
}
127140

128141
static class DummyEntity2 {
129-
@Id
130-
Long id;
142+
Long id = 0L;
131143

132144
public Long getId() {
133145
return id;

0 commit comments

Comments
 (0)