Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Enable Single Query Loading for simple aggregates. #1572

Closed
wants to merge 12 commits into from

Conversation

schauder
Copy link
Contributor

Single Query Loading loads as the name suggests complete aggregates using a single select.
While the ultimate goal is to support this for all aggregates, this commit enables it only for simple aggregate and also only for some operations.
A simple aggregate is an aggregate that only reference up to one other entity and does not have embedded entities.
The supported operations are those available via CrudRepository: findAll, findById, and findAllByIds.

Single Query Loading does NOT work with the supported in memory databases H2 and HSQLDB, since these do not properly support windowing functions, which are essential for Single Query Loading.

To turn on Single Query Loading call RelationalMappingContext.setSingleQueryLoadingEnabled(true).

Closes #1446
See #1450
See #1445

Single Query Loading loads as the name suggests complete aggregates using a single select.
While the ultimate goal is to support this for all aggregates, this commit enables it only for simple aggregate and also only for some operations.
A simple aggregate is an aggregate that only reference up to one other entity and does not have embedded entities.
The supported operations are those available via `CrudRepository`: `findAll`, `findById`, and `findAllByIds`.

Single Query Loading does NOT work with the supported in memory databases H2 and HSQLDB, since these do not properly support windowing functions, which are essential for Single Query Loading.

To turn on Single Query Loading call `RelationalMappingContext.setSingleQueryLoadingEnabled(true)`.

Closes #1446
See #1450
See #1445
@schauder schauder requested a review from mp911de July 21, 2023 17:04
schauder and others added 5 commits August 8, 2023 12:36
Extract Single Query Loading branching to SingleQueryFallbackDataAccessStrategy. Inline AggregateReaderFactory into SingleQueryDataAccessStrategy. Move CachingSqlGenerator to AggregateReader as caching root.

Introduce DataAccessStrategyFactory to encapsulate configuration.
Fix Javadoc tag ordering. Remove superfluous MappingContext parameters when Converter is available. Simplify code. Reformat code.
@mp911de mp911de added the type: enhancement A general enhancement label Aug 9, 2023
@mp911de mp911de added this to the 3.2 M2 (2023.1.0) milestone Aug 9, 2023
@mp911de
Copy link
Member

mp911de commented Aug 9, 2023

Applied a first round of polishing. I want to add another splitter implementation for the result set to read result segments into a map-of-maps structure for easier result processing. Essentially, moving the problem of the ResultSet advancing into an aggregated form to decouple advancing from mapping. That way, we have individual components that can be tested independently and we can have adapters for JDBC/R2DBC while the conversion part remains API-agnostic.

Transform the tabular structure into a graph of RowDocument associated with nested documents and lists. So far, this only works for singular top-level properties and embeddables holding single values.
We now support nested entities and entities in Lists.
Remove debugging statements, simplify tests.
@rishiraj88
Copy link

To "decouple advancing from mapping" is really a nice approach. Thanks, @mp911de .

Move RowDocumentExtractor into its own class hierarchy and decouple it from AggregateResultSetExtractor. Generify RowDocumentExtractor to allow various types of results in preparation for R2DBC. Introduce Iterator of RowDocument to simplify iteration.
Add container license acceptance for updated container images.
mp911de pushed a commit that referenced this pull request Aug 15, 2023
Single Query Loading loads as the name suggests complete aggregates using a single select.
While the ultimate goal is to support this for all aggregates, this commit enables it only for simple aggregate and also only for some operations.
A simple aggregate is an aggregate that only reference up to one other entity and does not have embedded entities.
The supported operations are those available via `CrudRepository`: `findAll`, `findById`, and `findAllByIds`.

Single Query Loading does NOT work with the supported in memory databases H2 and HSQLDB, since these do not properly support windowing functions, which are essential for Single Query Loading.

To turn on Single Query Loading call `RelationalMappingContext.setSingleQueryLoadingEnabled(true)`.

Closes #1446
See #1450
See #1445
Original pull request: #1572
mp911de added a commit that referenced this pull request Aug 15, 2023
Extract Single Query Loading branching to SingleQueryFallbackDataAccessStrategy. Inline AggregateReaderFactory into SingleQueryDataAccessStrategy. Move CachingSqlGenerator to AggregateReader as caching root.

Introduce DataAccessStrategyFactory to encapsulate configuration.

Fix Javadoc tag ordering. Remove superfluous MappingContext parameters when Converter is available. Simplify code. Reformat code.

Reorder Functions methods. Tweak Javadoc, move composite function into SingleQuerySqlGenerator.

See #1446
See #1450
See #1445
Original pull request: #1572
mp911de added a commit that referenced this pull request Aug 15, 2023
Transform the tabular structure into a graph of RowDocument associated with nested documents and lists.

Add container license acceptance for updated container images.

See #1446
See #1450
See #1445
Original pull request: #1572
@mp911de mp911de closed this Aug 15, 2023
@mp911de
Copy link
Member

mp911de commented Aug 15, 2023

That's merged and polished now.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Load aggregates that have a single one-to-m relationship with a single select
3 participants