Support COUNT(THIS) in string-based query execution
Jakarta Query defines the following grammar rule for aggregate expressions:
aggregate_expression : 'COUNT' '(' 'THIS' ')';
This allows for string-based queries such as:
SELECT COUNT(THIS) FROM Word
Eclipse JNoSQL currently supports parsing and executing string-based queries via Jakarta Query integration. However, support for this aggregation expression is not yet implemented.
Goal
Enable SELECT COUNT(THIS) FROM Entity in string-based queries and ensure it is correctly interpreted and executed within Eclipse JNoSQL.
Technical Context
Eclipse JNoSQL already provides an internal mechanism to handle count-based queries through:
SelectQuery.isCount()
Reference: SelectQuery.java#L86–L88
When the parser detects COUNT(THIS), it should toggle the SelectQuery's isCount flag accordingly.
💡 Usage Example
SELECT COUNT(THIS) FROM Word WHERE term = 'java'
This functionality must also be compatible with Jakarta Data repositories:
@Repository
public interface WordRepository {
@Query("SELECT COUNT(THIS) FROM Word WHERE term = 'java'")
Long countJava();
}
✅ Tasks
- [ ] Update the Jakarta Query parser integration in Eclipse JNoSQL to recognize the
COUNT(THIS)aggregate expression. - [ ] When
COUNT(THIS)is parsed, setSelectQuery.counttotrue. - [ ] Ensure the communication layer processes queries with
isCount = truecorrectly. - [ ] Add tests to validate
COUNT(THIS)queries return correct results across supported databases. - [ ] Verify compatibility with Jakarta Data's
@Querysyntax.