1 Introduction - Reference Documentation
Authors: Graeme Rocher, Burt Beckwith
Version: 5.0.8.RELEASE
1 Introduction
MongoDB bridges the gap between key-value stores (which are fast and highly scalable) and traditional RDBMS systems (which provide rich queries and deep functionality).MongoDB (from "humongous") is a scalable, high-performance, open source, document-oriented database.This project aims to provide an object-mapping layer on top of Mongo to ease common activities such as:- Marshalling from Mongo to Groovy/Java types and back again
- Support for GORM dynamic finders, criteria and named queries
- Session-managed transactions
- Validating domain instances backed by the Mongo datastore
1.1 Compatibility with GORM for Hibernate
This implementation tries to be as compatible as possible with GORM for Hibernate. In general you can refer to the GORM documentation and the "Domain Classes" section of the reference guide (see the right nav) for usage information.The following key features are supported by GORM for Mongo:- Simple persistence methods
- Dynamic finders
- Criteria queries
- Named queries
- Inheritance
- Embedded types
- Query by example
- HQL queries
- Composite primary keys
- Many-to-many associations (these can be modelled with a mapping class)
- Any direct interaction with the Hibernate API
- Custom Hibernate user types (custom types are allowed with a different API)
1.2 Release Notes
Below are the details of the changes across releases:5.0
- MongoDB 3.x driver support
- New Codec Persistence Engine
- Removal of GMongo
- Trait based
4.0
- Grails 3 compatibility
3.0
- Support for MongoDB 2.6
- MongoDB 2.6 GeoJSON type support (
MultiPoint,MultiLineString,MultiPolygonandGeometryCollection) - Support for Maps of embedded entities
- Flexible index definition
- Full text search support
- Support for projections using MongoDB aggregation
- Size related criteria implemented (
sizeEq,sizeLtetc.) on collections
2.0
- GeoJSON shape support
- Support for SSL connections
- Support for MongoDB connection strings
1.3
- Support for stateless mode to improve read performance
- Support for dynamically switching which database or collection to persist to at runtime
1.2
MongoDB plugin 1.2 and above requires Grails 2.1.5 or 2.2.1 as a minimum Grails version, if you are using older versions of Grails you will need to stay with 1.1
1.1 GA
- DBRefs no longer used by default for associations
- Upgrade to GMongo 1.0 and Spring Data MongoDB 1.1
- Support for global mapping configuration
1.0 GA
- Initial feature complete 1.0 release
1.3 Upgrade Notes
Configuration Properties
In previous versions of the plugin configuration was specified using the `grails.mongo` prefix. This is now `grails.mongodb` instead. For example, the following configuration inapplication.groovy or Config.groovy:grails {
mongo {
databaseName = 'foo'
}
}grails {
mongodb {
databaseName = 'foo'
}
}Persistence Engine
Since GORM for MongoDB 5.0 there is now a choice of persistence engine. The original GORM for MongoDB converted MongoDB documents to and from Groovy objects. This engine is still present and can be activated with the following configuration ingrails-app/conf/application.yml:grails:
mongodb:
engine: mappinggrails:
mongodb:
engine: codec