Skip to content

feat: Add applyFilter on projected query#108

Merged
chinhtrung merged 3 commits intomainfrom
trungnguyen.addFeatureToApplyFilterOnProjectedQuery
Feb 10, 2026
Merged

feat: Add applyFilter on projected query#108
chinhtrung merged 3 commits intomainfrom
trungnguyen.addFeatureToApplyFilterOnProjectedQuery

Conversation

@chinhtrung
Copy link
Contributor

@chinhtrung chinhtrung commented Feb 7, 2026

Following up from this comment about the need to apply filter usage on a projected query. I put up this PR to add applyFilter method that can be called on the projection.

Copy link
Collaborator

@QuinnB73 QuinnB73 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks

@chinhtrung chinhtrung enabled auto-merge (squash) February 10, 2026 19:14
* This will be either:
* * [TypeSafeCriteriaBuilder], for normal queries (supports applyFilter {})
* * [ProjectedTypeSafeCriteriaBuilder], for queries with projections (does not support extra applyFilter {})
* * [ProjectedTypeSafeCriteriaBuilder], for queries with projections (supports applyFilter {} for adding WHERE/JOIN/ORDER conditions)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this feels slightly misleading bc the one before also supports apply filter "for adding WHERE/JOIN/ORDER conditions" right? there is no difference on the applyFilter for TypeSafeCriteriaBuilder and ProjectedTypeSafeCriteriaBuilder ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true yeah, I can update it. There should be no difference in the applyFilter for both TypeSafeCriteriaBuilder and ProjectedTypeSafeCriteriaBuilder.

* the lambda returning the projection can be applied. For non-projected queries, there is no problem in applying
* multiple lambdas.
* Both builders support applying filters through the applyFilter method. The difference is that
* ProjectedTypeSafeCriteriaBuilder does not allow calling project() within applyFilter since the projection
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does the non-project one support that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah no, we don't have any filter method that does projection. Let me update it for clarity

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like I know you can (Must) call project at the end of the first lambda for ProjectedTypeSafeCriteriaBuilder

but I think you cannot do it in the lambda for applyFilter for TypeSafeCriteriaBuilder
it has an applyProjection method of its own

so I am thinking we just move the applyFilter to the parent? would that make sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, thank you!

@chinhtrung chinhtrung merged commit 31d2303 into main Feb 10, 2026
7 checks passed
@chinhtrung chinhtrung deleted the trungnguyen.addFeatureToApplyFilterOnProjectedQuery branch February 10, 2026 21:05
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.

3 participants