sbglasius opened a new issue, #16563:
URL: https://github.com/apache/grails-core/issues/16563
### Feature Request
`PredicateGenerator.CriterionHandlerProvider` works well for adding custom
criteria to the Hibernate 7 criteria
builder. We use it in grails-postgresql-extensions to port its PostgreSQL
array, hstore and json criteria from the
Hibernate 5 Criteria API.
Two things are missing for plugins like this:
1. **Resolving property paths.** `CriterionHandler.handle` receives the
query, the root and the criteria builder, but
not the `JpaQueryContext`. A handler therefore cannot resolve an alias
created with `createAlias` to the join that
GORM uses for it. It has to create or guess a join itself, and when a
GORM criterion on the same alias comes later,
GORM creates another join, so the two criteria can match different rows
of a to-many association. Passing the
`JpaQueryContext` to the handler (or a resolver for property paths) would
let custom criteria use the same joins as
the built-in ones.
2. **Ordering by an expression.** `JpaCriteriaQueryCreator.assignOrderBy`
only orders by property paths, so there is
no way to order by an SQL formula or `random()`, which the Hibernate 5
`Order` subclasses allowed. Today we add a
criterion whose handler inserts into `CriteriaQuery.getOrderList()`. That
relies on `assignOrderBy` running before
`assignCriteria`. A way to contribute a JPA `Order` for a custom
`Query.Order` subclass would avoid that.
### Environment Information
- Grails / GORM 8.0.0, `grails-data-hibernate7`
### Example Application
https://github.com/gpc/grails-postgresql-extensions/pull/136
(`plugin-hibernate7`)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]