Hibernate 7: a collection criterion next to an association block of the same collection throws ClassCastException
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- Groovy
- Star
- 2.9k
- Fork
- 976
- Merge trung bình
- 21 giờ 14 phút
- Pull request đã merge (30 ngày)
- 174
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của apache/grails-core
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
apache/grails-core#16635 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
apache/grails-core#16289 · 5 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
apache/grails-core#15764 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Update documentation for Java 25Có thể đã có người làm @ruthst00 đã nhận 10 ngày trước. Đang mởrelates-to: documentation weekly-action-item
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
apache/grails-core#15725 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 18/100
apache/grails-core#16634 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của apache/grails-core
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
melgarafael/DeskcommCRM#3000 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
OFN writer emits `DocIRI` as a bare IRI, which becomes a version IRI or a parse error on re-readĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
phillord/horned-owl#338 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
ai-driven-qa bug Cosmetic
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100