spring-projects / spring-projects/spring-data-jpa

How to JpaSpecificationExecutor and @QueryHints [DATAJPA-1637]

Open
#1,938 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: enhancement
Dominant language
Java
Stars
3.3k
Forks
1.6k
PR merge metrics
No merged PRs in 30d

Description

cancel opened DATAJPA-1637 and commented

Hello, im use JpaSpecificationExecutor. How i can cache these query with hibernate second level cache. @QueryHints does not work

@Override
@QueryHints(value = { @QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true")})
public Optional<ControlType> findByIdAndOrganization(Long id, Organization organization) {
return controlTypeRepository.findOne(spec.byId(id).and(spec.byOrganization(organization)));
}


Affects: 2.1.13 (Lovelace SR13)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reported JpaSpecificationExecutor.findOne call and the @QueryHints usage shown in the issue, then check how Hibernate second-level query caching is configured for the affected 2.1.13 version. Reproduce whether CACHEABLE is applied to the specification query; done means identifying the supported behavior or documenting a confirmed fix with a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.