Skip to content

Allow extension of JPA criteria query predicate building#2941

Closed
gnodet wants to merge 1 commit intoapache:mainfrom
gnodet:fix/jpa-criteria-visitor-extension
Closed

Allow extension of JPA criteria query predicate building#2941
gnodet wants to merge 1 commit intoapache:mainfrom
gnodet:fix/jpa-criteria-visitor-extension

Conversation

@gnodet
Copy link
Contributor

@gnodet gnodet commented Mar 10, 2026

Summary

  • Makes doBuildPredicate and doBuildCollectionPredicate methods protected in AbstractJPATypedQueryVisitor to allow subclasses to customize predicate construction
  • Adds getEntityManager() accessor to AbstractJPATypedQueryVisitorTest for use in test subclasses
  • Adds CustomJPACriteriaVisitor and JPACriteriaQueryVisitorExtensionTest demonstrating the extension capability

This is based on #2798 by @mkarg, with the following improvements:

  • Fixed checkstyle compliance (converted tabs to spaces, corrected import ordering)
  • Fixed test assertions: used path.getModel() instead of path.getAlias() (which returns null) for attribute identification
  • Fixed collection predicate test to use count(authors) syntax that actually triggers the collection check path

Closes #2798

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.
@gnodet
Copy link
Contributor Author

gnodet commented Mar 10, 2026

Superseded — pushed fixes directly to #2798 instead (merge from main + checkstyle/test fixes).

@gnodet gnodet closed this Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant