Grails Unit Test "CreateAlias" not working

I am trying to do a unit test using the namedquery method, and it does not work since I am using the grails.orm.HibernateCriteriaBuilder.createAlias ​​method, which Grails did not seem to find: "No signature Method: grails.gorm.CriteriaBuilder.createAlias ​​() "

I assume the problem is that when creating a unit test and making fun of the class, it tries to find the method around the grails.gorm.CriteriaBuilder class, not grails.orm.HibernateCriteriaBuilder , 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 method signature: grails.gorm.CriteriaBuilder.createAlias ​​()

+7
source share
1 answer

We could not understand this; we suspect that this is simply missing from the implementation of the GORM UnitTest. But if you just want to request an association, you do not need an alias in Grails. Note:

 Book.createCriteria { eq("title", "One Hundred Years of Solitude") author { eq("name", "Gabriel García Márquez") } } 
+2
source

All Articles