Grails hibernate create criteria multiple AND OR 条件

Grails hibernate create criteria multiple AND OR Conditions

我能够使用 grails/Hibernate 如下创建条件进行 3 个条件查询

 def c = Domain.createCriteria()

    c.list(max: map.max ?: 10, offset: map.offset ?: 0) {

            and {
                "colStatus" in status
                "code" in codes
            }
            and {
                or {
                    ilike("pCode", pCode)
                    ilike("pDesc", pCode)
                }
            }

        order("DateCol3", "desc")
    }

现在我有另外 3 个带有内部 OR 条件的添加条件,我需要将它们添加到查询中。我尝试关注但没有成功

 def c = Domain.createCriteria()

    c.list(max: map.max ?: 10, offset: map.offset ?: 0) {

            and {
                "colStatus" in status
                "code" in codes
            }
            and {
                or {
                    ilike("pCode", pCode)
                    ilike("pDesc", pCode)
                }
            }

            and {
                or {
                    ilike("eCode", eCode)
                    ilike("eDesc", eCode)
                }
            }

            and {
                or {
                    ilike("oCode", oCode)
                    ilike("oDesc", oCode)
                }
            }

        order("DateCol3", "desc")
    }

请建议并帮助我如何添加多个 AND/OR 条件。

我通过引入括号解决了这个问题

def c = Domain.createCriteria()

c.list(max: map.max ?: 10, offset: map.offset ?: 0) {

        {
            "colStatus" in status
            "code" in codes
        }
        ( {
            or {
                ilike("pCode", pCode)
                ilike("pDesc", pCode)
            }
        }
      )
      (
       {
            or {
                ilike("eCode", eCode)
                ilike("eDesc", eCode)
            }
        }
      )
      (  and {
            or {
                ilike("oCode", oCode)
                ilike("oDesc", oCode)
            }
        }
      )
    order("DateCol3", "desc")
}