Grails 1.2 M2 is out!

 

For those of you that know me, you will know that I am a big fan of Grails and Groovy. This week we have had 2 huge announcements. Firstly that VMWare has acquired SpringSource (Groovy and Grails custodian), and then Grails 1.2 M2 got released yesterday.

I downloaded 1.2 M2 last night and I am super keen to start using some of the new features! Find out about them here. Or download it now!

I am totally in love with the Named Queries which allows you to create pre-defined queries (with a name) in the domain class that you can consequently re-use in the application. Example from the release notes;

class Publication {
   String title
   Date datePublished
   static namedQueries = {
       recentPublications {
           def now = new Date()
           gt 'datePublished', now - 365
       }

       publicationsWithBookInTitle {
           like 'title', '%Book%'
       }

   }

}

You can do
// get all recent publications…
def recentPubs = Publication.recentPublications()
// get all recent publications (alternate syntax)…
def recentPubs = Publication.recentPublications.list()

// get up to 10 recent publications, skip the first 5…
def recentPubs = Publication.recentPublications(max: 10, offset: 5)
def recentPubs = Publication.recentPublications.list(max: 10, offset: 5)

// get the number of recent publications…
def numberOfRecentPubs = Publication.recentPublications.count()

// get a recent publication with a specific id…
def pub = Publication.recentPublications.get(42)

The other exciting changes is that tomcat is now the default container for building apps in, but this is accomplished through the plugin architecture, so it is just as easy to uninstall Tomcat and re-install Jetty again. Brilliant!!

Another win for me is the pre-compilation of GSPs in the WAR deployment. I host many of my grails apps on Virtual Private Servers, which usually have limited resource capabilities. So i find they constantly fall over at startup. This should certainly help that cause.

Other features worth a mention include;

  • Named URL Mappings
  • Support for hasOne mapping in the domain classes
  • Implementation of Spring 3 into the codebase and therefore support for all Spring 3 annotations

So it is time to get programming!!!

UPDATE: Just came across this one too. As of 1.2 Grails now creates your IntelliJ Project files too!! As a user of IDEA, this is just awesome.

Leave a Comment

© 2012 robjam.es