Skip to content

3.0.1

Compare
Choose a tag to compare
@julgus julgus released this 26 May 13:45
· 127 commits to master since this release

Description

Query Optimizations

The terminal operations findAny(), findFirst(), anyMatch(Predicate p), or noneMatch() have all been optimized to be merged into the database query. As an example, anyMatch(Predicate p) will be translated to a WHERE expression (applying the predicate p) and a LIMIT of 1.

Query Hints
JPAStreamer now supports query hints. These are useful in complex scenarios, or when dealing with specific database systems, to provide additional guidance to the underlying JPA provider for optimal query execution. The query hints influence e.g. the execution plan chosen by the JPA provider, potentially leading to improved query performance or tailored behavior based on specific requirements.

To pass a query hint to the underlying JPA provider with JPAStreamer, you need to use a StreamConfiguration. It exposes a method withHint() that accepts the name and value of the query hint. This method call can be chained to set multiple hints:

import org.hibernate.annotations.QueryHints;
...

StreamConfiguration sc = StreamConfiguration.of(Film.class)
          .withHint(QueryHints.FETCH_SIZE, 50)
          .withHint(QueryHints.READ_ONLY, true));

List<Film> films = jpaStreamer.stream(sc)
         .filter(Film$.title.startsWith("A"))
         .sorted(Film$.length)
         .collect(Collectors.toList());

Special thanks to Manuel Serra (@nitroin) for this great contribution!

Fixed issues
#320 Implements @QueryHints or similar
#31 Optimize terminating operations
#321 StreamConfigurations using Projections are being cached