Back

TechnologyMay 31, 2012

Getting Started with GORM

Tim Sporcic

Grails has proven itself to be a highly productive programming framework here at Credera. Grails combines the power of the Groovy programming language with a solid convention-over-configuration web framework, all running on top of the Java Virtual Machine (JVM). Once a new Grails developer has made it past the basics of writing application controllers and domain classes, the first major stumbling block is usually working with GORM, the Grails Object Relational Mapping layer. GORM makes it exceedingly easy to do simple queries against a domain class by properties, but it can quickly become convoluted when you need to use some of the more powerful concepts you might know in SQL, such as joins, distincts and other aggregate functions.

All of these are possible in GORM because, at its roots, GORM is based on the proven Hibernate framework.The trick for a new Grails developer is figuring out how to take advantage of these features. To simplify things for new Grails developers, I have developed a series of GORM recipes that walk a Grails developer through a successively more complicated series of recipes that cover typical GORM usage scenarios. The driving factor of the recipes is to demonstrate that GORM is capable of all the advanced query semantics a developer would typically use in a real-world application, without having to drop in to raw SQL to do it. These recipes are a great headstart for any Grails developer new to GORM, or as a quick refresher on how to solve specific query scenarios for experienced Grails developers.

The recipes and sample project are available on GitHub at http://timsporcic.github.com/GORM-Recipes/.