I try to check a method in my service, but I get an error all the time, which
String-based queries, such as [findAll], are not currently supported in this GORM implementation. Use criteria instead.
My service:
class MyService {
List<Color> colorShade (String shade) {
def shadeId = Shade.findByName(shade).id
return ColorShade.get(shadeId)
}
}
My class that integrates Shadeand Colordomains
class ColorShade extends Serializable {
Color color
Shade shade
static ColorShade create (Color color, Shade shade, boolean flush = false) {
if (get(shade.id) == null)
new ColorNetwork(color: color, shade: shade).save(flush: flush)
}
static ColorShade get (long shadeId) {
ColorShade.findAll 'from ColorShade where shade.id = :shadeId',
[shadeId: shadeId]
}
static mapping = {
table 'color_shade'
version false
id composite: ['color', 'shade']
}
}
My specification: test\unit\MyServiceSpec.groovyI also tried adding it totest\integration\MyServiceSpec.groovy
@TestFor(MyServiceSpec)
@Mock([Color, Shade, ColorNetwork])
@TestMixin(DomainClassUnitTestMixin)
class MyServiceSpec extends Specification {
def shade
def color
def setup(){
color = new Color(name: "red")
shade = new Shade(name: "dark")
color.save(flush: true)
shade.save(flush: true)
ColorShade.create(color, shade)
}
def cleanup () {
}
def "test colorShade" () {
expect:
1 == service.colorShade("dark").size()
}
}
When I run this test, I get an error message:
String-based queries like [findAll] are currently not supported in this implementation of GORM. Use criteria instead.
Question
- How can I check this? I'm on grails 2.2.4
Note. This is just a sample test case that I created for the purpose of the question. My actual tests are different, but in them I have the same problem as this question.
birdy