In one of the projects, we had used Query Caching to improve the performance. However, it also meant that the updates/inserts into a table did not get reflected immediately, i.e. something like: DomainClass.findByPropertyName("propertyName", [cache: true]) returned the same list as it was, before the insertion/updation took place....
Recently, we had a requirement where secure URLs were to be made accessible to Google. Our implementation was to send a url with token valid for 10 seconds. The token expired automatically after 10 seconds. We used time based cache for this as described here: T set max time to 10 seconds , I set default MaxAge to 10 millis in above...
Sometimes it is required that multiple Grails projects, hosted on a different Grails version, run simultaneously. In this case, while fixing bugs, you are required to run the application after switching the Grails version each time. To handle this scenario, I wrote a utility shell script "runGrails" to use a particular version of...
Following is an example of unidirectional one-to-many relationship: class Employee { String name static hasMany = [roles: Role] } class Role { String name } How can we find all the employees with a particular role - "Grails Developer"? Role role = Role.findByName("Grails Developer") One way of doing...
Recently i worked upon redirecting all the log related to a specified package in my project to a specific file. It seem very helpful as it provide precise context about run of your application and make it easier to debug as compare to low level debugging method such as println. Here we can also disable certain logs statement as per our...
Hey, SOAP is one of the popular ways of working with web-services another being REST (another of my blog)), while working with any of the SOAP based API, you will get a WSDL (web services description/definition language) describing what all methods are supported by the web service. Its a rather complicated XML document. A few days...
Hi, In one of our projects, we had a requirement for using some existing Business Process Management tool. JBPM is one such tool that we are evaluating. Our first step was to run a "Hello World" process from inside the grails application. On searching over the internet, I didn't find any helpful article/blog on integrating JBPM...
Recently, in my project I had to implement search functionality. I used grails createCriteria to implement it.Now I needed to apply the sorting on the result returned. My domain was something like this : class MyEntity { OrganizationName orgName PersonName personName static constraints = { ...
It is very easy and handy to use Grails <g:uploadForm> tag insteed of using HTML <form> tag or grails <g:form> tag, as you don't need to set the enctype attritbute to multipart/form-data (as in case of HTML <form> tag or grails <g:form> tag) to work with file upload. for example insteed of using: ... ...
Hi Friends, To retrieve difference between two dates with finer details which would display their difference as 2 years 7 weeks 3 days 2 hours 5 mins ago is given below. /** * Returns differnce b/w new Date and old date as Map holding difference in years, weeks, days, hrs, mins & secs */ public static Map...
This post might help you if you want to get JSON (JavaScript Object Notation) Object on browser. Grails framework provides you very efficient way to achieve this. For this you need to import grails JSON convertor in your code. import grails.converters.JSON Below is the code snapshot which converts java based lists of Objects to...
Hi Friends, I always used to spend lot of time writing integration tests as running even a single test involves loading the complete application, which includes loading complete database every time. Then I realized that data which I use for testing is always the same, why can't we restore the database once created, before we run the...