[英]Grails 2.2.2 createCriteria throwing error
我查看了互联网,但除了使用Grails 2.2.2的Jira Issue Im之外,什么都没找到,该问题影响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"])
}
}
完整的stacktrace错误:
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'])
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.