Skip to content

Fix embeddable projection retrieval#3774

Open
radovanradic wants to merge 16 commits into
5.1.xfrom
radovanradic/issue-3668
Open

Fix embeddable projection retrieval#3774
radovanradic wants to merge 16 commits into
5.1.xfrom
radovanradic/issue-3668

Conversation

@radovanradic

Copy link
Copy Markdown
Contributor

Fix for issue #3668

@radovanradic radovanradic marked this pull request as ready for review March 24, 2026 16:00
Copilot AI review requested due to automatic review settings March 24, 2026 16:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes issue #3668 by enabling repository methods to return embedded/embeddable projections (and nested embedded projections) by generating correct result metadata and SQL column projections/aliases so result mapping can hydrate the embeddable type instead of attempting scalar conversion.

Changes:

  • Treat embeddable query return types as DataType.ENTITY in the annotation processor so runtime mapping uses entity/embedded mapping.
  • Update SQL projection building to expand embedded projections into their constituent columns and alias columns to match embeddable property names (including nested embedded cases).
  • Add processor-, JDBC(H2)-, and Hibernate(JPA)-level tests covering embedded projection retrieval (including nullable and nested embedded projections) and an invalid projection type case.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
data-tck/src/main/java/io/micronaut/data/tck/repositories/RestaurantRepository.java Adds repository methods that project embedded fields directly (required for reproducing/fixing #3668).
data-processor/src/test/groovy/io/micronaut/data/processor/sql/BuildQuerySpec.groovy Adds query-generation assertions and result datatype assertions for embedded and nested embedded projections, plus a negative test.
data-processor/src/main/java/io/micronaut/data/processor/visitors/RepositoryTypeElementVisitor.java Marks embeddable query results as DataType.ENTITY to drive correct runtime mapping.
data-model/src/main/java/io/micronaut/data/model/query/builder/sql/AbstractSqlLikeQueryBuilder.java Expands embedded projections into column lists and aliases columns to embeddable property names (supports nested embedded).
data-jdbc/src/test/java/io/micronaut/data/jdbc/h2/H2VehicleRepository.java Introduces a JDBC H2 repository used to validate nested embedded projection retrieval.
data-jdbc/src/test/groovy/io/micronaut/data/jdbc/h2/H2EmbeddedSpec.groovy Adds integration tests for embedded projection retrieval (non-null, nullable, and nested embedded).
data-hibernate-jpa/src/test/java/io/micronaut/data/hibernate/UserWithWhereRepository.java Adds an embeddable projection method in the Hibernate JPA test repo.
data-hibernate-jpa/src/test/groovy/io/micronaut/data/hibernate/AbstractHibernateQuerySpec.groovy Adds a Hibernate test asserting embedded audit projection retrieval works.

Copilot AI review requested due to automatic review settings March 25, 2026 10:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 25, 2026 11:00
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
1 New Critical Issues (required ≤ 0)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.

@radovanradic radovanradic requested a review from Copilot March 25, 2026 15:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Copilot AI commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

@radovanradic I've opened a new pull request, #3780, to work on those changes. Once the pull request is ready, I'll request review from you.

#3780)

* Initial plan

* Align processor-side embeddable DataType resolution with runtime-side logic

Co-authored-by: radovanradic <10271067+radovanradic@users.noreply.github.com>
Agent-Logs-Url: https://github.com/micronaut-projects/micronaut-data/sessions/ccd7e35c-c41e-4c35-a851-04ac7c384bb2

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: radovanradic <10271067+radovanradic@users.noreply.github.com>
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
1 New Critical Issues (required ≤ 0)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Copilot AI review requested due to automatic review settings April 27, 2026 15:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Copilot AI review requested due to automatic review settings April 28, 2026 10:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated no new comments.

@radovanradic radovanradic requested a review from dstepanov April 28, 2026 10:42
@sonarqubecloud

Copy link
Copy Markdown

@radovanradic radovanradic requested review from msupic and removed request for msupic April 30, 2026 08:11
@radovanradic radovanradic added the type: bug Something isn't working label May 18, 2026
@radovanradic radovanradic changed the base branch from 5.0.x to 5.1.x May 29, 2026 14:34
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
2 New Critical Issues (required ≤ 0)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants