O'Reilly logo

Programming Grails by Burt Beckwith

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 3. Persistence

The persistence strategy in Grails is called Grails object relational mapping, or GORM. In earlier versions of Grails, this was a wrapper around Hibernate’s ORM implementation, but has been abstracted to allow access to other data sources, including NoSQL datastores like MongoDB, Redis, and Neo4j. GORM for Hibernate has been retrofitted to follow the new GORM API, which provides a consistent developer experience regardless of the underlying storage implementation. See the grails-data-mapping project on GitHub for more detailed information.

But it is not merely a least-common-denominator approach where only the features that are common to all datastores are supported. Instead, there is a core set of functionality that all implementations must provide (mapping from domain classes to datastore storage, supporting dynamic finders and Criteria queries, and so on) but each provider also supports access to the underlying implementation to access noncore features directly.

This means that, for data that fits the relational model well, you can use Hibernate to manage persistence in a relational database; but, for less structured data or to support more dynamic schemas, you can use a NoSQL datastore. The Grails NoSQL plug-ins coexist well with Hibernate, so you are free to store all of your data in a relational database, all in one or more NoSQL datastores, or use a mix.

See the extensive GORM documentation in the Grails reference for more information.

Data Mapping

The convention ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required