Skip to content

Commit 9f1acc6

Browse files
committed
reproduce issue and narrow down the place where the problem occurs.
See #1646
1 parent 077655f commit 9f1acc6

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/MappingJdbcConverter.java

+1
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ public <T> T getPropertyValue(RelationalPersistentProperty property) {
380380
aggregatePath.getRequiredPersistentPropertyPath());
381381

382382
if (property.isCollectionLike()) {
383+
// this simply returns List, but we might expect for example a Set.
383384
return (T) allByPath;
384385
}
385386

spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/AbstractJdbcAggregateTemplateIntegrationTests.java

+14
Original file line numberDiff line numberDiff line change
@@ -1268,6 +1268,13 @@ void multipleCollectionsWithEmptyList() {
12681268
assertThat(reloaded.mapElements.get("delta")).isEqualTo(new MapElement("four"));
12691269
}
12701270

1271+
@Test
1272+
void recordOfSet() {
1273+
Author tolkien = template.save(new Author(null, Set.of(new Book("Lord of the Rings"))));
1274+
1275+
Iterable<Author> authors = template.findAll(Author.class);
1276+
}
1277+
12711278
private <T extends Number> void saveAndUpdateAggregateWithVersion(VersionedAggregate aggregate,
12721279
Function<Number, T> toConcreteNumber) {
12731280
saveAndUpdateAggregateWithVersion(aggregate, toConcreteNumber, 0);
@@ -2079,6 +2086,13 @@ record SetElement(String name) {
20792086
record MapElement(String name) {
20802087
}
20812088

2089+
record Author(@Id Long id, Set<Book> books) {
2090+
}
2091+
2092+
record Book(String name) {
2093+
2094+
}
2095+
20822096
@Configuration
20832097
@Import(TestConfiguration.class)
20842098
static class Config {

spring-data-jdbc/src/test/resources/org.springframework.data.jdbc.core/JdbcAggregateTemplateIntegrationTests-hsql.sql

+11
Original file line numberDiff line numberDiff line change
@@ -368,3 +368,14 @@ CREATE TABLE MAP_ELEMENT
368368
MULTIPLE_COLLECTIONS_KEY VARCHAR(10),
369369
NAME VARCHAR(100)
370370
);
371+
372+
CREATE TABLE author
373+
(
374+
ID BIGINT GENERATED BY DEFAULT AS IDENTITY (START WITH 1) PRIMARY KEY
375+
);
376+
377+
CREATE TABLE book
378+
(
379+
author BIGINT,
380+
name varchar(100)
381+
);

0 commit comments

Comments
 (0)