Chapter 14. Understanding Spring and transactions

 

This chapter covers

  • Introducing the Spring framework
  • Working with transactions
  • Mastering transactions

As you’ve seen throughout the book, Grails isn’t only about giving you the tools to write web applications. It also provides the means to structure your application in a standard way, whether that’s through a service layer or a more asynchronous, message-oriented architecture as described in chapter 15. This isn’t by chance: the middle tier of your application (the business logic) is important because it normally provides the real business value.

The reason Grails works so well in this area is that it’s built on top of the incredibly popular and powerful Spring framework. We mentioned it in passing a few times, and it tends to remain invisible when your Grails applications don’t have complex business logic. You happily rely on services being automatically injected into your controllers and other artifacts. Yet when an application does increase in complexity, you won’t want to miss out on the help Spring can provide.

Understanding the basics of Spring is essential to writing flexible and maintainable Grails applications. Fortunately, Grails gives you a gradual learning curve to Spring that we take advantage of in this chapter to dig deeper and tease out the key features that will help you day to day. We also look at maintaining data integrity through transactions, which is one of the core features of Spring.

14.1. Spring fundamentals

14.2. Using transactions with GORM

14.3. Summary and best practices

sitemap