Standalone GORM

2,365 views
2,191 views

Published on

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,365
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
23
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Standalone GORM

  1. 1. Standalone GORM<br />Michael Collado<br />
  2. 2. What is Hibernate?<br />Object –Relational mapping tool<br />Object-Oriented querying<br />Database agnostic query language<br />XML configuration or annotations<br />
  3. 3. Typical Hibernate Java bean and configuration<br />Event.java<br />Event.hbm.xml<br />
  4. 4.
  5. 5. What is GORM?<br />Groovy layer over Hibernate<br />Convention over configuration mapping<br />Dynamic finder/persistence methods<br />DSL based querying<br />
  6. 6. Equivalent GORM entity definition<br />Event.groovv<br />
  7. 7.
  8. 8. GORM in Java<br />Hurdles<br />No dynamic methods in Java<br />No dynamic typing in Java<br />Cross-compilation<br />Semicolons<br /><ul><li>Solutions
  9. 9. Maven groovy plugin
  10. 10. Intermediary entity manager</li></li></ul><li>Configure Maven build<br />pom.xml<br />
  11. 11. Set up GORM in Spring<br />GORM XML namespace<br />
  12. 12. Add sessionFactory bean and dependencies<br />
  13. 13. Create TestBean entity<br />TestBean.groovy<br />
  14. 14. Create TestBean entity<br />
  15. 15. Use Java interface to bridge Java - Groovy<br />EntityManager.java<br />TestBeanManager.java<br />
  16. 16. Using GORM dynamic methods<br />TestBeanManagerImpl.groovy<br />
  17. 17. This works… but…<br />My database schema looks like this:<br />
  18. 18. Groovy Metaprogramming<br />Use JDK Proxy to implement interfaces<br />Use Groovy MetaMethods to call GORM methods dynamically<br />invokeMethod<br />methodMissing<br />
  19. 19. DynamicManagerImpl.groovy<br />
  20. 20. Demo<br />

×