You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
An association block inside or { } drops the rows without the association on Hibernate 5 and 7 #16924
An association block inside or { } drops the rows that have no such association, even when another branch of the or matches them.
TestEntity.withCriteria {
or {
child { eq('name', 'kid') }
eq('name', 'orphan')
}
}
// expected: the entity named 'with' (its child is 'kid') and the entity named 'orphan' (no child)// actual on Hibernate 5 and Hibernate 7: only 'with'
The same happens for a to-many block (pets { eq('name', 'rex') } beside eq('firstName', 'Barney')): the person without pets is lost. eq('child', instance), isNull('child') and isNotNull('child') inside or are correct on every binding.
Measured with a shared TCK spec (CriteriaOrAssociationSpec, in the PRs linked below):
UnsupportedOperationException: Join queries are not supported by MongoDB (by design)
So Hibernate 5 and 7 agree with each other and differ from what or means. Expected fix: the block has to be a left join (or an existence test) when it is under a disjunction. Not fixed here, because it changes results for existing queries and wants a decision.
The GORM reference settles which behavior is intended. The criteria guide (Hibernate 5 and Hibernate 7, "Querying Associations") documents exactly this shape:
def results = c.list {
or {
between('created', now -10, now)
transactions {
between('date', now -10, now)
}
}
}
and says: "Here we find all accounts that have either performed transactions in the last 10 days OR have been recently created in the last 10 days."
An account created recently that has no transactions is therefore documented to be found. Hibernate 5 and 7 drop it, because the association block is an inner join. So this is a bug against the documented behavior, not a choice, and Neo4j's fix in #16836 matches the documentation.
The docs are explicit that createAlias is an inner join by default and takes a join type argument, so that path is documented as inner. Only the block form inside or is documented as "either / or".
Plan: fix the block-under-disjunction case on Hibernate 5 (7.0.x) and Hibernate 7 (8.0.x) with a left join, add the block cells (including to-many) to the shared TCK with Mongo excluded because it does not support association blocks, and leave the createAlias behavior unchanged.
Activity
borinquenkid commentedon Nov 11, 2026
The GORM reference settles which behavior is intended. The criteria guide (Hibernate 5 and Hibernate 7, "Querying Associations") documents exactly this shape:
and says: "Here we find all accounts that have either performed transactions in the last 10 days OR have been recently created in the last 10 days."
An account created recently that has no transactions is therefore documented to be found. Hibernate 5 and 7 drop it, because the association block is an inner join. So this is a bug against the documented behavior, not a choice, and Neo4j's fix in #16836 matches the documentation.
The docs are explicit that
createAliasis an inner join by default and takes a join type argument, so that path is documented as inner. Only the block form insideoris documented as "either / or".Plan: fix the block-under-disjunction case on Hibernate 5 (7.0.x) and Hibernate 7 (8.0.x) with a left join, add the block cells (including to-many) to the shared TCK with Mongo excluded because it does not support association blocks, and leave the
createAliasbehavior unchanged.borinquenkid commentedon Nov 11, 2026
Fixes opened: #16930 (Hibernate 7, 8.0.x) and #16931 (Hibernate 5, 7.0.x). Neo4j is fixed by #16836.