Skip to content

Add support for combining @EntityGraph and Specification<T> [DATAJPA-1824] #2113

@spring-projects-issues

Description

@spring-projects-issues

Ruslan Stelmachenko opened DATAJPA-1824 and commented

Currently you can extend JpaSpecificationExecutor and use it's methods that support Specification<T> argument.

You can also create custom methods in repository interface with @EntityGraph annotation to control fetching of entity attributes.

But what is missing is the ability to combine Specification<T> argument and @EntityGraph annotation in custom methods. To make it work spring-data-jpa should support custom methods with Specification<T> argument (in addition to methods already present in JpaSpecificationExecutor).

The reason why this is important: Specification<T> defines the "where" (conditions) part of a query, while @EntityGraph defines the "select" (what fields to fetch) part of a query. So they are 2 independent things which can work together complementing each other.

The same is actually true for Projections. They define "what fields to fetch", but usually it's not enough because service layer must also pass a predicate to instruct repository layer on "what conditions to use"


Affects: 2.4.1 (2020.0.1)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions