You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I observed inconsistent behavior and API when trying to reuse and compose DetachedCriteria instances together:
Criteria composition seems to only work with closure based detached criterias
It seems there is no way to compose two detached criteria instances together (DetachedCriteria.where(DetachedCriteria))
closure based detached criterias do not work in a type-safe environment @GrailsCompileStatic
Tested with Grails 3.2.4
Some examples to demonstrate
// this is the only variant that works
def myFilter = {} as DetachedCriteria<Person>
Person.where(myFilter)
// this doesn't work, resulting in exception:
// No signature of method: Person.where() is applicable for argument types: (grails.gorm.DetachedCriteria)
def myFilter = new DetachedCriteria(Person).build {}
Person.where(myFilter)
// type-safe variant mit @GrailsCompileStatic doesn't even compile:
// [Static type checking] - Cannot assign value of type groovy.lang.Closure <Person> to variable of type grails.gorm.DetachedCriteria <Person>
DetachedCriteria<Person> myFilter = {} as DetachedCriteria<Person>
Person.where(myFilter)
@jamesdh At some point I was annoyed about this as well, but I think I encountered this in earlier Grails 3.x versions. The current API of detached criteria does seem to support join types:
I observed inconsistent behavior and API when trying to reuse and compose DetachedCriteria instances together:
DetachedCriteria.where(DetachedCriteria)
)Tested with Grails 3.2.4
Some examples to demonstrate
The text was updated successfully, but these errors were encountered: