Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
GORM Inside & Out
Graeme Rocher
Grails Project Lead
@graemerocher
rocherg@ociweb.com
Agenda
• GORM Introduction
• History of GORM
• GORM Source Code Tour
• Future of GORM
GORM Introduction
• Persistence layer used by Grails
• But, usable outside of Grails too
• Object mapping library with sup...
History of GORM
GORM 1.0
• Procedural meta-programming enhancement
for(domainClass	in	application.domainClasses)	{	
		domainClass.metaClas...
GORM 1.0
• Meta-programming presented problems
• Slower
• Harder to debug
• Harder to document
GORM 2.0
• Some procedural meta-programming enhancement
• ….and AST Transformations!!
domainClassNode.addMethod(	
			new	M...
GORM 3.0
• Only AST Transformations!!
• Bye bye runtime meta-programming….
domainClassNode.addMethod(	
			new	MethodNode("...
GORM 2.0 / 3.0
• AST transformations were faster and
more performant, but
• Still harder to debug
• Still hard to document
GORM 5.0
• Only a few AST Transformations
• … and Traits!
trait	GormEntity	{	
			void	save()	{	
						datastore	
							.c...
GORM 5.0
• Traits are:
• Easier debug
• Easier to document
• Fast
• @CompileStatic for the win!
GORM 5 - Hibernate
• Support for Hibernate 3, 4 and 5 (and
5.1)
• Completely rewritten and based on
traits
• Grails 2, Gra...
GORM 5 - MongoDB
• Rewritten for MongoDB 3.x driver
• Uses codecs to avoid Document to
Object conversion (much faster)
• G...
GORM 5 - Neo4j
• Rewritten for Neo4j 2.3.x
• Robust Cypher and Transaction support
• Embedded, REST & HA modes
supported
•...
GORM Source Code
• https://github.com/grails/grails-data-
mapping
• Import with IntelliJ 16
• Build with Gradle
GORM SOURCE CODE TOUR
grails-datastore-core
• Core APIs applicable to all
• Object Mapping
• Dirty Checking
• Transaction Management
• Query API...
grails-datastore-core
• Classes of Interest
• MappingContext
• PersistentEntity
• PersistentProperty
• ToOne
• ToMany
• Em...
grails-datastore-core
• Classes of Interest
• Query
• Restrictions
• Projections
• Criteria
• BuildableCriteria
grails-datastore-gorm
• GORM Traits
• Public User Facing API
• Events
• Dynamic Finders
• Where Queries
grails-datastore-gorm
• Classes of Interest
• GormEntity
• GormStaticApi
• GormInstanceApi
• GormValidateable
• DynamicFin...
grails-datastore-gorm-tck
• Test compatibility kit
• Run for all implementations
• Hundreds of integration tests
grails-datastore-gorm-*
• -mongodb - GORM for MongoDB
• -hibernate - GORM for Hibenrate
• -neo4j - GORM for Neo4j
• -cassa...
Coming in GORM 6
• RxGORM
• MongoDB RX Support
• RxGORM REST Client
• Neo4j 3.x / Bolt Driver
• Native Multi Tenancy
3.0
RxGORM
• GORM for RxJava
• Reactive
• Stateless
• Non-Blocking
• Lightweight
3.0
DEMO - RxGORM
Q & A
Thank You!
Graeme Rocher
rocherg@ociweb.com
ociweb.com/grails
Come speak to the OCI Grails Team!
Web: grails.org
StackOverflow: http://stackoverflow.com/tags/grails
Slack: http://slack...
Gr8Conf 2016 - GORM Inside and Out
Upcoming SlideShare
Loading in …5
×

Gr8Conf 2016 - GORM Inside and Out

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.

  • Be the first to comment

Gr8Conf 2016 - GORM Inside and Out

  1. 1. GORM Inside & Out
  2. 2. Graeme Rocher Grails Project Lead @graemerocher rocherg@ociweb.com
  3. 3. Agenda • GORM Introduction • History of GORM • GORM Source Code Tour • Future of GORM
  4. 4. 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
  5. 5. History of GORM
  6. 6. GORM 1.0 • Procedural meta-programming enhancement for(domainClass in application.domainClasses) { domainClass.metaClass.save = {-> sessionFactory .currentSession.persist(this) } }
  7. 7. GORM 1.0 • Meta-programming presented problems • Slower • Harder to debug • Harder to document
  8. 8. GORM 2.0 • Some procedural meta-programming enhancement • ….and AST Transformations!! domainClassNode.addMethod( new MethodNode("save", PUBLIC, …) )
  9. 9. GORM 3.0 • Only AST Transformations!! • Bye bye runtime meta-programming…. domainClassNode.addMethod( new MethodNode("save", PUBLIC, …) )
  10. 10. GORM 2.0 / 3.0 • AST transformations were faster and more performant, but • Still harder to debug • Still hard to document
  11. 11. GORM 5.0 • Only a few AST Transformations • … and Traits! trait GormEntity { void save() { datastore .currentSession.save(this) } }
  12. 12. GORM 5.0 • Traits are: • Easier debug • Easier to document • Fast • @CompileStatic for the win!
  13. 13. 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
  14. 14. 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
  15. 15. 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
  16. 16. GORM Source Code • https://github.com/grails/grails-data- mapping • Import with IntelliJ 16 • Build with Gradle
  17. 17. GORM SOURCE CODE TOUR
  18. 18. grails-datastore-core • Core APIs applicable to all • Object Mapping • Dirty Checking • Transaction Management • Query API • Configuration
  19. 19. grails-datastore-core • Classes of Interest • MappingContext • PersistentEntity • PersistentProperty • ToOne • ToMany • Embedded
  20. 20. grails-datastore-core • Classes of Interest • Query • Restrictions • Projections • Criteria • BuildableCriteria
  21. 21. grails-datastore-gorm • GORM Traits • Public User Facing API • Events • Dynamic Finders • Where Queries
  22. 22. grails-datastore-gorm • Classes of Interest • GormEntity • GormStaticApi • GormInstanceApi • GormValidateable • DynamicFinder
  23. 23. grails-datastore-gorm-tck • Test compatibility kit • Run for all implementations • Hundreds of integration tests
  24. 24. grails-datastore-gorm-* • -mongodb - GORM for MongoDB • -hibernate - GORM for Hibenrate • -neo4j - GORM for Neo4j • -cassandra - GORM for Cassandra • -test - GORM for ConcurrentHashMap
  25. 25. Coming in GORM 6 • RxGORM • MongoDB RX Support • RxGORM REST Client • Neo4j 3.x / Bolt Driver • Native Multi Tenancy 3.0
  26. 26. RxGORM • GORM for RxJava • Reactive • Stateless • Non-Blocking • Lightweight 3.0
  27. 27. DEMO - RxGORM
  28. 28. Q & A
  29. 29. Thank You! Graeme Rocher rocherg@ociweb.com ociweb.com/grails
  30. 30. Come speak to the OCI Grails Team! Web: grails.org StackOverflow: http://stackoverflow.com/tags/grails Slack: http://slack-signup.grails.org Twitter: @grailsframework

×