gpt4 book ai didi

grails - Grails 2.2.2 createCriteria抛出错误

转载 作者:行者123 更新时间:2023-12-02 15:07:49 25 4
gpt4 key购买 nike

我查看了互联网,但除了这个Jira Issue Im以外,什么都没有找到。我使用 Grails 2.2.2 ,该问题影响 1.7.10 ,但仍然不是resolved这样。

问题

当我将eq('code', 'guitar')更改为'in'('code', ["guitar", "bass", "flute"])

我收到错误:

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"])
}
}

完整的堆栈跟踪错误:
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'])
}
}

关于grails - Grails 2.2.2 createCriteria抛出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24160310/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com