I am trying to make a unit test over a namedquery method and it´s not working as I am using the method grails.orm.HibernateCriteriaBuilder.createAlias which doesn´t seem to be found by Grails: " No signature of method: grails.gorm.CriteriaBuilder.createAlias()"
I guess the problem is that when making a unit test and mocking the class, it´s trying to find the method around "grails.gorm.CriteriaBuilder" class and not grails.orm.HibernateCriteriaBuilder class, why ?? any ideas to solve it?
class Book{
static namedQueries = {
testMethod()
{
createAlias('name', 'james')
}
}
}
@Mock([Book])
class BookTests{
@Test
void myTest() {
Book.testMethod();
}
}
Error : No signature of method: grails.gorm.CriteriaBuilder.createAlias()
We couldn't figure this out either; we suspect it's just missing from the GORM UnitTest implementation. But if you just want to query an association, in Grails you don't need an alias. Observe:
Book.createCriteria {
eq("title", "One Hundred Years of Solitude")
author {
eq("name", "Gabriel García Márquez")
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With