Grails 2.2.2 createCriteria抛出错误

Grails 2.2.2 createCriteria抛出错误,grails,groovy,Grails,Groovy,我已经在互联网上搜索过了,但除了这个Im使用的Grails 2.2.2之外没有找到任何东西。这个问题影响1.7.10,但仍然没有解决 问题 当我将情商(‘代码’、‘吉他’)更改为(‘代码’、[‘吉他’、‘贝司’、‘长笛’) 我得到错误信息: org.codehaus.groovy.runtime.GStringImpl cannot be cast to java.lang.String 工作代码 //this code is working like expected def c = Pr

我已经在互联网上搜索过了,但除了这个Im使用的Grails 2.2.2之外没有找到任何东西。这个问题影响1.7.10,但仍然没有
解决

问题

当我将情商(‘代码’、‘吉他’)更改为(‘代码’、[‘吉他’、‘贝司’、‘长笛’)

我得到错误信息:

org.codehaus.groovy.runtime.GStringImpl cannot be cast to java.lang.String
工作代码

//this code is working like expected 
def c = Project.createCriteria();
this.ids = c.list {
    projections {
        property 'id'
    }
    instruments{
        eq('code', 'guitar')
    }
}
//when I change the code to this one I get the error.
def c = Project.createCriteria();
this.ids = c.list {
    projections {
        property 'id'
    }
    instruments{
        //### This line create the problem!!
        'in'('code', ["guitar", "bass", "flute"])
    }
}
不工作代码

//this code is working like expected 
def c = Project.createCriteria();
this.ids = c.list {
    projections {
        property 'id'
    }
    instruments{
        eq('code', 'guitar')
    }
}
//when I change the code to this one I get the error.
def c = Project.createCriteria();
this.ids = c.list {
    projections {
        property 'id'
    }
    instruments{
        //### This line create the problem!!
        'in'('code', ["guitar", "bass", "flute"])
    }
}
完整堆栈跟踪错误:

org.codehaus.groovy.runtime.GStringImpl cannot be cast to java.lang.String. Stacktrace follows:
Message: org.codehaus.groovy.runtime.GStringImpl cannot be cast to java.lang.String
    Line | Method
->> 1618 | invokeMethod     in grails.orm.HibernateCriteriaBuilder
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    230 | search           in sound.domain.ProjectPagingService$$EOgryxiS
|    193 | search . . . . . in com.sound.ProjectController$$EOgrT45Y
|    150 | invoke           in net.bull.javamelody.JspWrapper
|    281 | invoke . . . . . in net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler
|     82 | doFilterInternal in com.linkedin.grails.profiler.ProfilerFilter
|    202 | doFilter . . . . in net.bull.javamelody.MonitoringFilter
|    180 | doFilter         in     ''
|   1145 | runWorker . . .  in java.util.concurrent.ThreadPoolExecutor
|    615 | run              in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run . . . . . .  in java.lang.Thread
任何帮助都将不胜感激


谢谢

问题似乎是您在列表中使用了双引号,请尝试以下方法:

this.ids = Project.withCriteria {

    projections {
        property 'id'
    }

    instruments{
        'in'('code', ['guitar', 'bass', 'flute'])
    }
}

是的!!!!!!!!!!!:))非常感谢。顺便说一句,数组是用params.entrySet().findAll{it.key.startsWith(“musicalStyles”)}动态创建的。每个{ms=“$it.value”;}
ms
数组
你知道如何用简单的代码更改双cote吗?这似乎是一个单独的问题,你能在这里写一篇新文章并粘贴链接吗?