Skip to content

feat: add GROUP BY, HAVING and Query/AdvancedQuery separation#143

Merged
brunomendola merged 3 commits intoqueritylib:mainfrom
vage88sg1:feature/group-by-having-implementation
Jan 16, 2026
Merged

feat: add GROUP BY, HAVING and Query/AdvancedQuery separation#143
brunomendola merged 3 commits intoqueritylib:mainfrom
vage88sg1:feature/group-by-having-implementation

Conversation

@vage88sg1
Copy link
Contributor

Add support for GROUP BY and HAVING clauses with a clear separation between simple entity queries and projection queries.

API Changes:

  • Query: simplified for entity-only queries (filter, sort, pagination, distinct)
  • AdvancedQuery: for projections with SELECT, GROUP BY, HAVING clauses
  • QueryDefinition: common interface for both query types
  • Querity.advancedQuery(): new entry point for projection queries
  • Querity.findAllProjected(): returns List<Map<String, Object>>

New Features:

  • GROUP BY with property names or expressions
  • HAVING clause for aggregate filtering
  • AdvancedQueryPreprocessor for preprocessing advanced queries
  • JpaQueryUtils to reduce code duplication

Implementation:

  • JPA, MongoDB, Elasticsearch backend support
  • Parser support for GROUP BY and HAVING
  • Semantic validation (HAVING requires GROUP BY)
  • Null validation in withPreprocessor() methods
  • Immutable preprocessors list using List.copyOf()
  • Standardized exception handling across all factories

Add support for GROUP BY and HAVING clauses with a clear separation
between simple entity queries and projection queries.

API Changes:
- Query: simplified for entity-only queries (filter, sort, pagination, distinct)
- AdvancedQuery: for projections with SELECT, GROUP BY, HAVING clauses
- QueryDefinition: common interface for both query types
- Querity.advancedQuery(): new entry point for projection queries
- Querity.findAllProjected(): returns List<Map<String, Object>>

New Features:
- GROUP BY with property names or expressions
- HAVING clause for aggregate filtering
- AdvancedQueryPreprocessor for preprocessing advanced queries
- JpaQueryUtils to reduce code duplication

Implementation:
- JPA, MongoDB, Elasticsearch backend support
- Parser support for GROUP BY and HAVING
- Semantic validation (HAVING requires GROUP BY)
- Null validation in withPreprocessor() methods
- Immutable preprocessors list using List.copyOf()
- Standardized exception handling across all factories
- Update README examples to use advancedQuery() for projections and GROUP BY
- Add MockMvc integration tests for AdvancedQuery JSON binding
- Allow mixing propertyNames and expressions in SimpleGroupBy and SimpleSelect
- Add .factorypath to .gitignore
@vage88sg1 vage88sg1 force-pushed the feature/group-by-having-implementation branch from f9d9482 to 85fcfff Compare January 15, 2026 15:11
- Remove FUNCTION shorthand from ConditionDeserializer as it was untested
  and could cause issues with field mixing
- Keep explicit leftExpression format which is properly tested
- Document getEffectiveExpressions() ordering behavior in SimpleGroupBy
  and SimpleSelect Javadoc to clarify that propertyNames come before
  expressions, and interleaved insertion order is not preserved
@brunomendola brunomendola merged commit 96f892d into queritylib:main Jan 16, 2026
1 of 2 checks passed
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.

2 participants