简体   繁体   English

Grails createCriteria语法错误

[英]Grails createCriteria syntax error

I am trying to create a list of companies which appear in either of 2 other lists. 我正在尝试创建出现在其他2个列表中的任何一个的公司列表。 I can manage to create a list of companies appearing in 1 other list like this :- 我可以设法创建出现在其他1个列表中的公司列表,如下所示:-

       List masterList = Companies.createCriteria().list(){
            'in'("companyname", alistofcompanies) 
            and {
                or{
                    eq("type","T1")
                    eq("type","T2")
                }                
             order ("companyname")
            }     
        }

But I don't know how to look for companies in either of 2 other lists. 但是我不知道该如何寻找另外两个列表中的一个。 I tried this :- 我试过了:-

    List masterList = Companies.createCriteria().list(){
            or{
               'in'("companyname", alistofcompanies) 
               'in'("companyname", anotherlistofcompanies)
             }
            and {
                or{
                    eq("type","T1")
                    eq("type","T2")
                }                
             order ("companyname")
            }     
      }

but it gives me a syntax error. 但这给了我一个语法错误。

Any clues how I should structure this? 任何线索,我应该如何构造呢?

I don't see any syntax issue except you can improve the code and it is working. 除了可以改进代码之外,我看不到任何语法问题,它可以正常工作。

 List masterList = Companies.createCriteria().list() {
            'in'("companyname", alistofcompanies + anotherlistofcompanies)
            'in'("type", ["T1", "T2"])
             order("companyname")
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM