Scrivio Interview library
ScenarioIntermediate6 min read · updated 12 November 2026

A team uses Querydsl with Spring Data for dynamic filters. The upstream Querydsl project has had long periods of slow maintenance and a community fork exists. What do you do about it?

We first assess the actual risk: whether the original Querydsl and the community fork support Jakarta Persistence and Hibernate 6 or 7, how quickly each ships security fixes, and how often each releases, checking the current status rather than relying on memory. Then we choose between moving to the maintained fork, migrating to the JPA Criteria API or Spring Data Specifications, or adopting jOOQ for the complex SQL. Whatever we choose, Querydsl usage goes behind repository interfaces so the change is contained, the most complex queries migrate first with tests comparing results, and the decision goes into an ADR with a review date.

Why this question is asked

Querydsl was for years the default way to build type-safe dynamic queries with Spring Data, and many codebases rely on it for search screens with a dozen optional filters. When a library like that slows down, teams tend either to panic and rewrite everything, or to ignore it until a framework upgrade fails. Interviewers ask this scenario to see how a senior engineer handles dependency risk: measured, reversible and documented. In this answer, we will recap what Querydsl does for the team, assess the risk, compare the options, contain the dependency, migrate the hard queries with tests, and record the decision.

1A Quick Recap of What Querydsl Does Here

Querydsl generates query classes, Q-types, from JPA entities with an annotation processor: QOrder for Order, with typed paths such as QOrder.order.status. With Spring Data, a repository that extends QuerydslPredicateExecutor accepts a Predicate, so the team builds filters by combining optional conditions and passes them to findAll.

Java
public interface OrderRepository extends JpaRepository<Order, Long>,
QuerydslPredicateExecutor<Order> {}
BooleanBuilder where = new BooleanBuilder();
QOrder o = QOrder.order;
if (filter.status() != null) where.and(o.status.eq(filter.status()));
if (filter.minTotal() != null) where.and(o.total.goe(filter.minTotal()));
if (filter.customer() != null) where.and(o.customer.name.containsIgnoreCase(filter.customer()));
Page<Order> page = repo.findAll(where, pageable); // only the filters the user set

This is what any replacement must reproduce: optional conditions combined safely, type-checked paths, and paging through Spring Data.

2Assessing the Risk

Slow maintenance is a risk, not yet a problem. We turn it into facts. First, compatibility: does the version we use work with jakarta.persistence and with the Hibernate and Spring Data versions we plan to run next year, Hibernate 6 now and Hibernate 7 with Spring Boot 4? Querydsl historically shipped Jakarta support through a separate classifier, and the fork, maintained by the OpenFeign community, publishes under its own group id; check the current status and versions of both rather than trusting what was true last year. Second, security: are reported vulnerabilities in it or its dependencies fixed, and how fast? Third, cadence: when were the last few releases of each, and do they track new Java and Hibernate versions?

We also measure our own exposure: how many classes use Q-types, how many queries are simple filter combinations and how many are complex joins, subqueries or projections.

Risk assessment, filled with current facts
QuestionOriginal QuerydslCommunity fork
Jakarta Persistence supportcheck current statuscheck current status
Hibernate 6 / 7 testedcheck release notescheck release notes
Last releases and cadencecheck repositorycheck repository
Security fixescheck advisoriescheck advisories
Our usage40 classes, 120 predicates, 15 complex queriessame code
The answers change over time, which is why the ADR gets a review date.

3Comparing the Options

Moving to the maintained fork is the cheapest step if it is healthy: often a change of group id and imports, with the same API. It reduces the immediate risk but keeps us dependent on a smaller community. Migrating to Spring Data Specifications, which are built on the standard JPA Criteria API, removes the third-party dependency entirely; Specifications compose with and() and or() much like predicates, and the JPA static metamodel, generated by Hibernate's annotation processor, gives type-safe attribute names. The cost is more verbose code, especially for joins and subqueries. Adopting jOOQ fits if the complex queries are really SQL-shaped reports, but it is a bigger change and works from the schema rather than the entities.

Java
// The same filter with Spring Data Specifications and the JPA static metamodel
static Specification<Order> hasStatus(Status s) {
return (root, q, cb) -> s == null ? null : cb.equal(root.get(Order_.status), s); // null = no condition
}
static Specification<Order> minTotal(BigDecimal t) {
return (root, q, cb) -> t == null ? null : cb.greaterThanOrEqualTo(root.get(Order_.total), t);
}
Page<Order> page = repo.findAll(
Specification.where(hasStatus(filter.status())).and(minTotal(filter.minTotal())), pageable);
// repository extends JpaSpecificationExecutor<Order>

Notice that a Specification returning null means no condition, which gives the same optional-filter behaviour as the BooleanBuilder. For a team whose Querydsl use is mostly filters like these, Specifications are a realistic long-term home; check your Spring Data version for the preferred way to start a chain, as Specification.where has been joined by newer factory methods.

4Containing the Dependency

Whatever we choose, the first engineering step is the same: make sure Q-types and Querydsl predicates do not leak out of the data access layer. Today, controllers or services may build BooleanBuilders themselves. We introduce repository methods or a small query interface that take a plain filter object, OrderFilter with status, minTotal and customer, and keep all Querydsl code inside the implementation.

Java
public interface OrderSearch {
Page<Order> search(OrderFilter filter, Pageable pageable); // no Querydsl types in the signature
}
@Repository
class QuerydslOrderSearch implements OrderSearch { ... } // today
// class SpecificationOrderSearch implements OrderSearch { ... } // tomorrow, same callers

After this step, a migration touches only implementation classes, and we can even run two implementations side by side in tests.

5Migrating the Hard Queries First, With Tests

It is tempting to migrate the easy filters first because they show quick progress. We do the opposite. The fifteen complex queries, with joins, subqueries and projections, are where an option might fail, so migrating them first tells us early whether the chosen path really works. For each one we write a test on a real database that runs the old and the new implementation with the same filters and asserts identical results, including order and paging totals.

Step throughHandling the Querydsl risk
  1. Assess compatibility, security and cadenceoriginal and fork, current facts
  2. Hide Querydsl behind repository interfacesplain filter objects in signatures
  3. Is the fork healthy and compatible?
    YesMove to the fork now, plan further laterNoChoose Specifications or jOOQ
  4. Migrate the complex queries firstold and new compared in tests
  5. Write the ADR with a review daterevisit in 6 to 12 months

5 steps in order. Play them, or step through them one at a time.

6Recording the Decision

Finally, we write an architecture decision record, an ADR, a short document stating the context, the options, the decision and its consequences. Here it might say: we move to the community fork now because it supports our Hibernate version and fixes vulnerabilities, we have contained Querydsl behind OrderSearch and similar interfaces, and we will review in nine months or at the next major Spring Boot upgrade, with Specifications as the planned fallback. The review date matters because the facts behind the decision will change.

7Follow-up questions

Is moving to the fork just postponing the problem?

It can be, which is why it comes with containment and a review date. If the fork is active and compatible, it buys time at very low cost. Because the usage is now behind interfaces, a later move to Specifications or jOOQ remains a contained change rather than a rewrite.

Why not move straight to the Criteria API everywhere?

Because it is more verbose and the migration has a cost in time and risk. If most queries are simple filters, the move is reasonable. If many are complex, the Criteria API versions may be hard to read and maintain, and jOOQ or the fork may be the better home for those.

What would make us act urgently?

An unpatched security vulnerability in the library or a transitive dependency, or a planned upgrade, such as Hibernate 7 with Spring Boot 4, that the version we use cannot support. Either one turns a slow-burning risk into a deadline.

8Conclusion

In this answer, we handled slow upstream maintenance of Querydsl by assessing current compatibility, security fixes and release cadence of the original and the fork, comparing the fork, Spring Data Specifications on the Criteria API, and jOOQ, hiding Querydsl behind repository interfaces so any change is contained, migrating the most complex queries first with result comparison tests, and recording the decision in an ADR with a review date.

What to say in the interviewAbout 80 seconds aloud

Open with

I would treat it as a dependency risk to measure, not a reason to rewrite. First I would check the facts as they stand today, for both the original project and the community fork: Jakarta Persistence support, compatibility with our Hibernate 6 and the Hibernate 7 that comes with Spring Boot 4, how fast security issues are fixed, and how regularly each releases.

Then, if they want more

I would also measure our own usage, how many simple filters versus complex queries. The options are moving to the maintained fork, which is usually a cheap group id change, migrating to Spring Data Specifications on the JPA Criteria API, which removes the dependency but is more verbose, or using jOOQ for the complex SQL-shaped queries.

Whatever we pick, the first step is to hide Querydsl behind repository interfaces that take plain filter objects, so no Q-types leak into services and the migration stays contained.

Then I would migrate the most complex queries first, because they tell us whether the chosen path really works, with tests that run old and new implementations on a real database and compare results. And I would write an ADR with the decision and a review date, because the health of both projects will change.

About this answer

Last updated
12 November 2026
Versions it names
Hibernate 6, Hibernate 7, Spring Boot 4
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "A team uses Querydsl with Spring Data for dynamic filters. The upstream Querydsl project...": https://scrivio-interview-library.netlify.app/databases/jpa-queries/c599ce2481/