Grails

Clearing Hibernate Query Cache in Grails

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....

by Vivek Krishna
Tag: Grails
23-Jun-2010

Grails

Open Pdf in Google Docs using Time Based Cache in Grails

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...

by Hitesh Bhatia
Tag: Grails
23-Jun-2010

Grails

Script for Running Grails Projects of Different Versions Simultaneously

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...

by Vivek Krishna
Tag: Grails
18-Jun-2010

Grails

Grails criteria query example for unidirectional one-to-many relationships

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...

by Aman Aggarwal
Tag: Grails
14-Jun-2010

Grails

Configuring Log4J for logging level specific logs of different packages into file using appenders

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...

by Tarun Pareek
Tag: Grails
09-Jun-2010

Grails, Technology

Working With Soap Calls

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...

by Sachin
Tag: Grails
08-Jun-2010

Grails

Embedding JBPM 4.3 in a Grails 1.2.2 Application

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...

by Himanshu Seth
Tag: Grails
14-May-2010

Grails

Ordering using Grails CreateCriteria

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 = { ...

by Imran Mir
Tag: Grails
14-May-2010

Grails

Handy g:uploadForm

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: ... ...

by niraj
Tag: Grails
14-May-2010

Grails

Grails : Difference b/w two dates with fine-grained details

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...

by Amit Jain
Tag: Grails
14-May-2010

Grails

Create JSON object Using Grails converter (Only selective fields from lists of objects)

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...

by Salil
Tag: Grails
13-May-2010

Grails

Grails : Save time while writing Integration tests

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...

by Amit Jain
Tag: Grails
06-May-2010