CXF-9174: Allow customization of JPA FIQL predicate building#2798
CXF-9174: Allow customization of JPA FIQL predicate building#2798gnodet merged 1 commit intoapache:mainfrom
Conversation
|
Hi @reta, Let me know if you'd like any adjustments. |
|
@reta |
Yeah, something is unstable, I will rerun checks shortly |
|
@raoua-eng could you please fix checkstyle violations: |
|
Fixed whitespace and tab character issues. |
...sions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/CustomJPACriteriaVisitor.java
Show resolved
Hide resolved
.../src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPACriteriaQueryVisitorExtensionTest.java
Show resolved
Hide resolved
@raoua-eng could you please run |
|
@reta I ran mvn |
Thanks @raoua-eng , well, we cannot merge unless checks pass. If you are up to it, would be great to fix those, thank you |
Make doBuildPredicate and doBuildCollectionPredicate methods protected in AbstractJPATypedQueryVisitor to allow subclasses to customize predicate construction for specific properties or collection checks. Add getEntityManager() accessor to AbstractJPATypedQueryVisitorTest and new test classes demonstrating the extension capability. Based on PR apache#2798 by mkarg, with fixes for checkstyle compliance (tabs to spaces, import ordering) and corrected test assertions.
CI Failure AnalysisThe build failure on JDK 21 (and the cancellation on JDK 17) is caused by 2 checkstyle ImportOrder violations in the new test files. The other test failures (JMS timeout, tracing, Brave span counts) are pre-existing flaky tests unrelated to this PR. Checkstyle errorsBoth errors are
CXF's checkstyle rules require FixIn // Before (wrong):
import jakarta.persistence.metamodel.Bindable;
import org.apache.cxf.jaxrs.ext.search.ConditionType;
// After (correct):
import jakarta.persistence.metamodel.Bindable;
import org.apache.cxf.jaxrs.ext.search.ConditionType;In // Before (wrong):
import jakarta.persistence.criteria.CriteriaQuery;
import org.apache.cxf.jaxrs.ext.search.SearchCondition;
// After (correct):
import jakarta.persistence.criteria.CriteriaQuery;
import org.apache.cxf.jaxrs.ext.search.SearchCondition; |
…ted for extensibility Allow subclasses of AbstractJPATypedQueryVisitor to customize JPA predicate building by changing doBuildPredicate() and doBuildCollectionPredicate() from private to protected visibility. This enables the Template Method pattern for custom FIQL-to-JPA predicate generation without modifying the core visitor. Includes tests demonstrating a custom visitor with case-insensitive LIKE matching and collection predicate override.
4f7ac27 to
ebbcb4d
Compare
|
Thanks for cleanup @gnodet , non-code concern: the user has asked for this feature and then lost interest in it, I would prefer to hold on merging this change, it is ready but apparently not needed anymore. wdyt? |
|
I think it's worth merging — the production change is just The use case is legitimate: if you need custom JPA predicates (e.g., database-specific functions like accent-insensitive comparisons), you currently have to duplicate the entire visitor. With this change, you just override the predicate-building method. Whether or not the original requester still needs it, it's a reasonable extension point that others could benefit from. I'd rather merge it than let it go stale. |
…ted for extensibility (#2798) Allow subclasses of AbstractJPATypedQueryVisitor to customize JPA predicate building by changing doBuildPredicate() and doBuildCollectionPredicate() from private to protected visibility. This enables the Template Method pattern for custom FIQL-to-JPA predicate generation without modifying the core visitor. Includes tests demonstrating a custom visitor with case-insensitive LIKE matching and collection predicate override. Co-authored-by: Guillaume Nodet <gnodet@gmail.com> (cherry picked from commit 95a5856)
…ted for extensibility (#2798) Allow subclasses of AbstractJPATypedQueryVisitor to customize JPA predicate building by changing doBuildPredicate() and doBuildCollectionPredicate() from private to protected visibility. This enables the Template Method pattern for custom FIQL-to-JPA predicate generation without modifying the core visitor. Includes tests demonstrating a custom visitor with case-insensitive LIKE matching and collection predicate override. Co-authored-by: Guillaume Nodet <gnodet@gmail.com> (cherry picked from commit 95a5856)
This PR addresses CXF-9174.
It makes doBuildPredicate(...) and doBuildCollectionPredicate(...) protected to allow customization of predicate construction in JPACriteriaQueryVisitor.
A new test demonstrates how a custom visitor can override predicate behavior without duplicating the entire visitor implementation.
This enables use cases such as database-specific functions (e.g. accent-insensitive comparisons).