Skip to content

Treat id properties correctly in derived finder methods. #2164

New issue

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

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

Already on GitHub? Sign in to your account

Closed
michael-simons opened this issue Mar 2, 2021 · 0 comments
Closed

Treat id properties correctly in derived finder methods. #2164

michael-simons opened this issue Mar 2, 2021 · 0 comments
Assignees
Labels
type: bug A general bug

Comments

@michael-simons
Copy link
Collaborator

Single instances of domain objects can be projected as well. This can be done with standard projections, i.e. hardcoding the returned object like this:

interface TreestructureRepository extends Neo4jRepository<ProjectionTestRoot, Long> {

	Optional<AProjection> findById(Long id);
}

In this case, the normal findById mechanism kicks in and the id properties are treated correct (depending on whether internally or externally generated or externally assigned).

It is also possible to use dynamic projections like this

interface TreestructureRepository extends Neo4jRepository<ProjectionTestRoot, Long> {

	<T> Optional<T> findById(Long id, Class<T> typeOfProjection);
}

In this case, the part tree query mechanism (aka derived queries) kicks in and sadly, this one doesn't treat the id property correctly.
This will affect other derived finder methods as well that build upon the ID property.
The chance that someone actually uses a derived query method on a id is rather low, and the projecting case is one of the few good reasons todo so.

@michael-simons michael-simons added the type: bug A general bug label Mar 2, 2021
@michael-simons michael-simons added this to the 6.0.6 (2020.0.6) milestone Mar 2, 2021
@michael-simons michael-simons self-assigned this Mar 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

1 participant