You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Adjacent operators of the same type that preserve {Order, Type, State, Side Effect} can be squashed into one single equivalent operator:
This allows JPAStreamer to combine many filters into one WHERE clause. However, as a filters can only be applied to the SQL query if it uses a JPAStreamer predicate, the squashed predicate must also be a combination of JPAStreamer predicates to be applied on the query. As of now, JPAStreamer squashes all predicates, resulting in more operations being executed on the JVM side.
Expected behavior
Only adjacent filters using JPAStreamer predicates should be squashed.
Actual behavior
Predicates are merged regardless of the predicate type.
How To Reproduce
Run a query with two filters, one using a JPAStreamer predicate and one with an anonymous lambda. Observe in the Hibernate log that the first filter is not merged to the query. This happens as both filters are firsts squashed into an operator that cannot be merged into the query.
final List<Film> films = jpaStreamer.stream(Film.class)
.filter(Film$.length.greaterThan(120))
.filter(f -> f.getTitle().endsWith("A"))
.collect(Collectors.toList());
Build tool
e.g. Maven 3.9.0
JPAStreamer version
e.g. JPAStreamer 3.0.2
The text was updated successfully, but these errors were encountered:
julgus
changed the title
Incorrect merge of filter()-operator
Incorrect squash of filter() and sorted()-operator
Jul 10, 2023
julgus
changed the title
Incorrect squash of filter() and sorted()-operator
Merger should only squash adjacent filters and sorts that uses the JPAStreamer metamodel
Jul 10, 2023
julgus
changed the title
Merger should only squash adjacent filters and sorts that uses the JPAStreamer metamodel
Interopoptimizer should only squash adjacent filters and sorts that uses the JPAStreamer metamodel
Jul 10, 2023
Describe the bug
Adjacent operators of the same type that preserve {Order, Type, State, Side Effect} can be squashed into one single equivalent operator:
stream().filter(predicate1) .filter(predicate2) =
stream.filter(predicate1.and(predicate2))
This allows JPAStreamer to combine many filters into one WHERE clause. However, as a filters can only be applied to the SQL query if it uses a JPAStreamer predicate, the squashed predicate must also be a combination of JPAStreamer predicates to be applied on the query. As of now, JPAStreamer squashes all predicates, resulting in more operations being executed on the JVM side.
Expected behavior
Only adjacent filters using JPAStreamer predicates should be squashed.
Actual behavior
Predicates are merged regardless of the predicate type.
How To Reproduce
Run a query with two filters, one using a JPAStreamer predicate and one with an anonymous lambda. Observe in the Hibernate log that the first filter is not merged to the query. This happens as both filters are firsts squashed into an operator that cannot be merged into the query.
Build tool
e.g. Maven 3.9.0
JPAStreamer version
e.g. JPAStreamer 3.0.2
The text was updated successfully, but these errors were encountered: