Skip to content

Support unordered Collection properties.#2324

Closed
lsh1215 wants to merge 1 commit into
spring-projects:mainfrom
lsh1215:gh-848-unordered-collection
Closed

Support unordered Collection properties.#2324
lsh1215 wants to merge 1 commit into
spring-projects:mainfrom
lsh1215:gh-848-unordered-collection

Conversation

@lsh1215

@lsh1215 lsh1215 commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Summary

This change lets Spring Data JDBC represent unordered aggregate child collections that still allow duplicate elements by treating Collection differently from ordered List properties.

Root cause

BasicRelationalPersistentProperty previously classified every collection-like property except Set as list-like. As a result, Collection<Child> was treated as qualified and ordered, requiring an index/key column and using list-style generated-id aggregation.

Changes

  • Restrict list-like detection to arrays and List implementations.
  • Add a JDBC-side CollectionAggregator so generated child ids can be populated for unordered Collection properties without a qualifier.
  • Add mapping metadata coverage for Collection being collection-like but not qualified or ordered.
  • Add a JDBC integration regression test that saves and reloads duplicate child elements through Collection<CollectionElement> without a key column.
  • Add DB-specific schema fixtures for the new integration-test tables.

Verification

  • git diff --check upstream/main..HEAD
  • ./mvnw -pl spring-data-relational,spring-data-jdbc -Dtest=DefaultAggregatePathUnitTests,JdbcRepositoryWithListsIntegrationTests,JdbcRepositoryWithCollectionsIntegrationTests test

Closes #848.


  • You have read the Spring Data contribution guidelines.
  • You use the code formatters provided here and have them applied to your changes. Don’t submit any formatting related changes.
  • You submit test cases (unit or integration tests) that back your changes.
  • You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header (copy from another file and set the current year only).

Signed-off-by: Sanghun Lee <vitash1215@gmail.com>
@lsh1215 lsh1215 marked this pull request as ready for review June 28, 2026 16:57
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jun 28, 2026
@mp911de mp911de added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Jun 29, 2026
@schauder

schauder commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Thanks.

I moved the test so Single Query Loading gets tested as well.
And I added a little documentation.

This is merged.

@schauder schauder closed this Jul 6, 2026
@schauder schauder added this to the 4.2 M1 (2026.1.0) milestone Jul 6, 2026
@schauder schauder changed the title GH-848 - Support unordered Collection properties. Support unordered Collection properties. Jul 6, 2026
schauder pushed a commit that referenced this pull request Jul 6, 2026
Properties declared as type `Collection` can be stored an retrieved without a key column, resulting in an unordered collection and no index stored.

Duplicates will be preserved.

Closes #848
Original pull request #2324

Signed-off-by: Sanghun Lee <vitash1215@gmail.com>
schauder added a commit that referenced this pull request Jul 6, 2026
Moved test to Abstract JdbcAggregateTemplateIntegrationTests.
Added documentation.

See #848
Original pull request #2324
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: enhancement A general enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support List without @MappedCollection(keyColumn=) [DATAJDBC-630]

4 participants