Hibernate 7: a collection criterion next to an association block of the same collection throws ClassCastException
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
Direzione di ricerca
The failure is a ClassCastException where pets resolves to an SqmSetJoin instead of an SqmPluralValuedSimplePath, so start from how the Hibernate 7 criteria path resolves a property name that a join block has already created. Reproduce with the TCK Person and Pet domains, using the four cases in the issue (block first and criterion first, at top level and inside owner { }). Done means all four cases return the same results as Hibernate 6 and the regression tests pass.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Expected Behavior
A collection criterion such as isNotEmpty('pets') restricts the collection whether it comes before or after a pets { ... } block in the same criteria, at the top level or inside another association block.
Actual Behaviour
On Hibernate 7, unless the criterion comes before the block inside another association block, the query fails with:
java.lang.ClassCastException: class org.hibernate.query.sqm.tree.domain.SqmSetJoin cannot be cast to class org.hibernate.query.sqm.tree.domain.SqmPluralValuedSimplePath
The path pets resolves to the join the block made for the association instead of to the collection-valued path that isNotEmpty expects. At the top level this happens in either order, because the join type a block of the queried class records becomes an alias definition of the query.
Steps To Reproduce
With the TCK Person (hasMany = [pets: Pet]) and Pet (owner) domains on Hibernate 7:
// top level, block first: ClassCastException
Person.createCriteria().list {
pets { eq('name', 'Rex') }
isNotEmpty('pets')
}
// top level, criterion first: ClassCastException
Person.createCriteria().list {
isNotEmpty('pets')
pets { eq('name', 'Rex') }
}
// inside another block, block first: ClassCastException
Pet.createCriteria().list {
owner {
pets { eq('name', 'Rex') }
isNotEmpty('pets')
}
}
// inside another block, criterion first: works
Pet.createCriteria().list {
owner {
isNotEmpty('pets')
pets { eq('name', 'Rex') }
}
}
Found while reviewing https://github.com/apache/grails-core/pull/16559#discussion_r4256550230; the behaviour is the same with and without that PR.
Environment Information
- Hibernate 7 (
grails-data-hibernate7), Hibernate ORM 7.4.10 - JDK 21
Example Application
No response
Version
8.0.x
- Lingua principale
- Groovy
- Stelle
- 2.9k
- Fork
- 976
- Merge medio
- 20h 13m
- PR unite (30g)
- 168
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di apache/grails-core
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
apache/grails-core#16635 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
apache/grails-core#16289 · 5 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
apache/grails-core#15764 ·
I maintainer di solito rispondono entro 1 giorno
-
Update documentation for Java 25Forse già presa @ruthst00 l’ha presa 8 giorni fa. Apertarelates-to: documentation weekly-action-item
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
apache/grails-core#15725 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 18/100
apache/grails-core#16634 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di apache/grails-core
Issue simili
-
effort: low prio: low ready
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
digitalfabrik/integreat-cms#4621 ·
I maintainer di solito rispondono entro 5 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
onyx-dot-app/onyx#16016 ·
I maintainer di solito rispondono entro 1 giorno