As we know in Mongo the match queries are case sensitive. So whether we do a find() operation or use $match stage of aggregate pipeline, the condition would be true only if its a exact case sensitive match. Of cource we can use regex to do case insensitive queries but then again it will not work when we are trying to find a match with in...
In my last blog, we discussed how to hook into GORM API to add some common custom functionality. We will refer the same problem that we discussed in my last blog. Here is the problem statement: In my grails plugin I was needed to add some fields that were common to a set of domains. For eg: for some domains we wanted to store fields like...
In my grails plugin I was needed to add some fields that were common to a set of domains. For eg: for some domains we wanted to store fields like createdBy and lastUpdatedBy to keep track of users who created and last updated each record in that domain. Grails framework provides timestamping using which we can keep track of the time a...
I was trying to intercept method calls of a Grails Service class for a little while. Adding interceptors to Controllers is really easy and I wanted to intercept calls to one of the methods in a Service class in a similar fashion. But adding interceptors to Grails Service Classes is not as straightforward as for Controllers. After doing...
Sometimes in a web application we need filtering on request to a resource or on response, or on both. In Grails, it could be done easily via creating a filter. Just run grails create-filters [filter-name] and it will generate a filter in the application. To run a filter before all other filters, just put that filter at top of other...
In Grails 2.x and in some earlier versions, the log4j configuration resides in grails-app/conf/Config.groovy. We can modify log4j closure here to add new categories and tweak the log levels. In development environemnt any changes to log4j closure are loaded automatically without bouncing the application, but not when the application is...
Although in grails, we can use the logSql property in the DataSource file to log SQL queries or enable loggers "org.hibernate.SQL" for logging queries and "org.hibernate.type.descriptor.sql.BasicBinder" for logging bindings. But this solution wouldn't be that much helpful if we just want the logging for a particular piece of code rather...
There are times when we need to parse the URL mappings in our grails app. In my case we have a REST API. In which we have implemented a generic query method for all controllers but it is available to only a few using custom URL mappings. We wanted to create test cases in such a way for query action that each time a test case runs it...