So let me point you to APIs through which you can implement the following:
- Use jakarta.persistence.criteria.CriteriaBuilder#between}}and {{jakarta.persistence.criteria.CriteriaBuilder#coalesce
- Use jakarta.persistence.criteria.CriteriaBuilder#lessThanOrEqualTo and jakarta.persistence.criteria.CriteriaBuilder#sum with unsafe casts (please create an issue for improving this by adding new methods to HibernateCriteriaBuilder)
- This is just a regular subquery. Unless you don’t have entities mapped for the tables, you can just use the regular CriteriaQuery#subquery and jakarta.persistence.criteria.CriteriaBuilder#in as well as jakarta.persistence.criteria.CriteriaBuilder#not APIs
For the other examples, follow the same advice as in 3. and just use the subquery APIs. I know the JPA Criteria API is not as nice as simply writing a String, but overall, the end result will be easily portable, not only across JPA providers, but also across databases. |