Skip to content

Treat id properties correctly in derived finder methods. #2164

Closed
@michael-simons

Description

@michael-simons

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.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions