Grails project lead Graeme Rocher delivers a deep dive into GORM, the object mapping technology used by Grails, which provides support for Hibernate (SQL), MongoDB and Neo4j amongst other implementations.
5. GORM Introduction
• Persistence layer used by Grails
• But, usable outside of Grails too
• Object mapping library with support for
SQL, MongoDB, Neo4j, Cassandra and
more
• http://gorm.grails.org
9. GORM 2.0
• Some procedural meta-programming enhancement
• ….and AST Transformations!!
domainClassNode.addMethod(
new MethodNode("save", PUBLIC, …)
)
10. GORM 3.0
• Only AST Transformations!!
• Bye bye runtime meta-programming….
domainClassNode.addMethod(
new MethodNode("save", PUBLIC, …)
)
11. GORM 2.0 / 3.0
• AST transformations were faster and
more performant, but
• Still harder to debug
• Still hard to document
12. GORM 5.0
• Only a few AST Transformations
• … and Traits!
trait GormEntity {
void save() {
datastore
.currentSession.save(this)
}
}
13. GORM 5.0
• Traits are:
• Easier debug
• Easier to document
• Fast
• @CompileStatic for the win!
14. GORM 5 - Hibernate
• Support for Hibernate 3, 4 and 5 (and
5.1)
• Completely rewritten and based on
traits
• Grails 2, Grails 3, Spring Boot or
Standalone
15. GORM 5 - MongoDB
• Rewritten for MongoDB 3.x driver
• Uses codecs to avoid Document to
Object conversion (much faster)
• Grails 2, Grails 3, Spring Boot or
Standalone
16. GORM 5 - Neo4j
• Rewritten for Neo4j 2.3.x
• Robust Cypher and Transaction support
• Embedded, REST & HA modes
supported
• Grails 2, Grails 3, Spring Boot or
Standalone
17. GORM Source Code
• https://github.com/grails/grails-data-
mapping
• Import with IntelliJ 16
• Build with Gradle