My domain uses a hibernate filter like so:
class UserMapping {
// Senseless App Logic here
static hibernateFilters = {
typeFilter(condition: "type = 'IDENTIFIED'", default: true)
flagFilter(condition: "flags = 'ACTIVE'", default: true)
}
}
They seem to apply fine when I use them in the controller however when I do the same findBy.. in my service or job, they are not applied. Any suggestions?
If it makes any difference, I invoke the findBy in a mixin.
This question seems related but its not exactly what I’m looking for:
enabling grails hibernate filters
The only time filters are automatically enabled is during web requests – this is due to the plugin’s
HibernateFilterFiltersapplying all enabled filters before each web request. But there’s no global automatic filter logic – this would be impractical.Instead use one of the approaches described in the plugin documentation, e.g.