或标准 Grails 嵌套对象
OR criteria Grails nested objects
我正在尝试对两个嵌套对象使用带 OR 的 createCriteria。
这是我正在使用的代码:
or {
ordersSecondaryReceptionSystem {
eq('code', params.receptionSystemCode)
}
ordersReceptionSystem {
eq('code', params.receptionSystemCode)
}
}
只考虑了两者中的一个,次要的。
有什么我想念的吗?
我可以通过创建别名来修复它:
createAlias('ordersReceptionSystem', 'ordersReceptionSystem', Criteria.LEFT_JOIN)
createAlias('ordersSecondaryReceptionSystem', 'ordersSecondaryReceptionSystem', Criteria.LEFT_JOIN)
or {
eq('ordersReceptionSystem.code', params.receptionSystemCode)
eq('ordersSecondaryReceptionSystem.code', params.receptionSystemCode)
}
我正在尝试对两个嵌套对象使用带 OR 的 createCriteria。
这是我正在使用的代码:
or {
ordersSecondaryReceptionSystem {
eq('code', params.receptionSystemCode)
}
ordersReceptionSystem {
eq('code', params.receptionSystemCode)
}
}
只考虑了两者中的一个,次要的。 有什么我想念的吗?
我可以通过创建别名来修复它:
createAlias('ordersReceptionSystem', 'ordersReceptionSystem', Criteria.LEFT_JOIN)
createAlias('ordersSecondaryReceptionSystem', 'ordersSecondaryReceptionSystem', Criteria.LEFT_JOIN)
or {
eq('ordersReceptionSystem.code', params.receptionSystemCode)
eq('ordersSecondaryReceptionSystem.code', params.receptionSystemCode)
}