The Book
Title: Grails in Action
Authors: Glen Smith, Peter Ledbrook
Publisher: Manning
Review
The book is organized into four parts:
- Introduction: The very first chapter is aptly titled as ‘Grails In a Hurry’. If you are a complete beginner to Grails you will be blown away with the productivity and the powerful feature set of Grails on display. Many concepts explained in detail in the later chapters are summarized with a simple example. Second chapter goes over Groovy basics, which is adequate.
- Fundamentals: I think taking up a non-trivial example to explain the concepts of a framework is nice. A Twitter-like application is built during the course of this part of the book. This part explains about using GORM (Grails Object Relational Mapping Library), techniques for using Constraints for validation, power of Grails scaffolding, usage of dynamic queries, controlling application flow and the usage of services, introduction to GSPs and the discussion about views and layouts (along with AJAX stuff).
- Building more features into your applications: How well different levels of testing (unit, integration, functional) are integrated into the framework is discussed. This part then continues with the basics of plugins and their usage. One of my favorite chapters in this book follows next, workflow with Grails Webflow. Security is discussed in some detail, but the chapter that follows really stands out (especially for a huge REST fan like me) — explains how to design and implement a RESTful API showcasing Grails support for this architectural pattern.
- What you need to know for real work: The last part of the book explains about — messaging and scheduling, some advanced GORM concepts, how to use Spring and transactions with Grails, and about plugin development. The chapter on advanced GORM concepts is well written; folks who intend to use Grails for enterprise-level applications will certainly benefit from this chapter.
This is my first formal reading of a Grails book, but have some decent exposure to the concepts of Grails (from the available documentation, and by the presentations that I attended in the past). So for me, introductory chapters and some of the fundamentals are well-needed refreshers, but the last two parts really stand out. Some points from my notes:
- For integration tests, Grails bootstrap the database and wires up all components just as it would for a running web app.
- Domain class relationships (1:1, 1:M, M:N) are explained quite well from the Grails point of view — belongsTo variations, hasMany and GORM magic of automatically adding new methods to account for the defined relationships.
- Groovy querying with dynamic finders: Dynamic finders take advantage of funky Groovy metaclass magic to intercept all method calls on a domain object; leverages Groovy’s methodMissing feature.
- Use flash scope for passing messages to the user when a redirect is involved.
- Extensive discussion on the Grails form taglibs, and on creating your own tags.
- Mocking is built-in the framework for productive unit testing.
- Webflow introduces a new scope: flow scope. Items put in flow scope live for the life of the flow. Favor flow scope over session scope — Webflow will cleanup the storage for you and give you more efficient server memory.
- The chapter on implementing the REST architectural pattern is a must read; Grails supports the pattern out-of-the-box.
- Grails uses OSCache as its default cache library (for Hibernate’s second-level cache). The reason suggested was that it plays well with Grails developer restarts, something I would like to understand further in reference to Ehcache. But the authors actually used Ehcache in the book suggesting that it is a better library (I agree!).
- So easy to declare caching at the domain level:
static mapping = {cache: “read-write”
}
- Discussion on integrating with legacy databases is interesting, but would like to see some case studies to understand the real pain involved.
- Transactional services are implemented using Spring’s AOP mechanism (Spring’s TransactionProxyFactoryBean).
- Integration tests run inside a transaction by default, which is then rolled back after each test finishes. This ensures that data changes don’t affect other tests, but it means you can’t check whether transactions are rolled back or not. If you want to test transactional behavior then you need to add a static transactional property to your test.
Conclusion
The book is very well organized and the topics chosen are well thought of. An easy conversational tone is used through out the book. In my opinion, this book succeeds in building a sustained interest about the framework. It is also an excellent reference book on the topic. Strongly recommend the book for all Grails enthusiasts.
You may also like:

Follow on Twitter
Pingback: Book Review: Grails in Action | Business Article Source
#1 by bhaarat on April 25th, 2009
Quote
The book has not come out yet. how did you do the review?
[Reply]
Surya Suravarapu Reply:
April 25th, 2009 at 10:08 am
It is available at the publisher’s website as a part of their early access program (MEAP): http://manning.com/gsmith/
[Reply]
#2 by Kenrick Chien on May 4th, 2009
Quote
Surya, great review. I’ve been reading and reviewing the book as part of MEAP for several months now, and I agree, the book covers a lot of great topics. My personal favorite would have to be the unit and integration testing chapter. Grails support for mocking rocks!
[Reply]
Pingback: act:ualise technology | Evening reading.. Grails In Action and other Manning Books have useful free eBooks when paper copies are bought
#3 by Radu on September 21st, 2009
Quote
Hello,
Would you be interested in posting your book reviews on http://www.javabooks.org as well? There are reviewing partnerships available and you can receive free ebooks and nice discounts. Please contact me if this appeals to you.
Thanks!
[Reply]