gustavoharff commented on PR #16559:
URL: https://github.com/apache/grails-core/pull/16559#issuecomment-6071900854
While working on this PR I noticed that the Hibernate 7 criteria DSL only
takes the join type of an association block or of `createAlias` as a number:
```groovy
Pet.createCriteria().list {
owner(1) { // 1 = LEFT, 2 = RIGHT, anything else = INNER
face(1) { ... }
}
createAlias('owner', 'o', 1)
}
```
On Hibernate 5 those numbers came from `org.hibernate.sql.JoinType`
(`JoinType.LEFT_OUTER_JOIN.joinTypeValue`), but that class is gone since
Hibernate 6, so on Hibernate 7 there is no named constant left to pass and code
ends up with magic numbers.
What do you think about also accepting
`jakarta.persistence.criteria.JoinType`?
```groovy
owner(JoinType.LEFT) {
face(JoinType.LEFT) { ... }
}
createAlias('owner', 'o', JoinType.LEFT)
```
The numbers would keep working as they do today, so nothing breaks for code
coming from Hibernate 5. It would also match `DetachedCriteria.join(String,
JoinType)`, which already takes the JPA `JoinType`. The change is small: the
association block check and `createAlias` in `CriteriaMethodInvoker` /
`HibernateCriteriaBuilder`, plus tests.
If it sounds good, I can open a separate PR for it.
--
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]