I'm trying to use createCriteria with OR on two nested objects.
This is the code I'm working with:
or {
ordersSecondaryReceptionSystem {
eq('code', params.receptionSystemCode)
}
ordersReceptionSystem {
eq('code', params.receptionSystemCode)
}
}
Only one of the two are being taken into account, the secondary one. Is there something I'm missing?
I was able to fix it by creating an Alias:
createAlias('ordersReceptionSystem', 'ordersReceptionSystem', Criteria.LEFT_JOIN)
createAlias('ordersSecondaryReceptionSystem', 'ordersSecondaryReceptionSystem', Criteria.LEFT_JOIN)
or {
eq('ordersReceptionSystem.code', params.receptionSystemCode)
eq('ordersSecondaryReceptionSystem.code', params.receptionSystemCode)
}