08448380779 Call Girls In Civil Lines Women Seeking Men
Agile Database Modeling with Grails - Preview of GORM 1.4 - SF Grails Meetup 2011-03
1. Agile Database Modelling
New GORM Features in Grails 1.4
Prepared for SF Grails Café Centro
March 2011
by Christian Hang
Thanks to Taulia for hosting and food!!
2. Agenda
New (GORM) Features in Grails 1.4
Quick intro to H2
Reverse Engineering
Database Migrations
Other new Grails 1.4 features
Summary
3. New (GORM) Features in Grails 1.4
Replace HQSQL with H2
Best-of-bread in-memory DB
Built-in web console
4. New (GORM) Features in Grails 1.4
Replace HQSQL with H2
Best-of-breed in-memory DB
Built-in web console
Reverse Engineering
Based on Hibernate's reverse engineering
Create GORM classes from existing DB
5. New (GORM) Features in Grails 1.4
Replace HQSQL with H2
Best-of-bread in-memory DB
Built-in web console
Reverse Engineering
Based on Hibernate's reverse engineering
Create GORM classes from existing DB
Database Migrations
Based on Liquibase
"Revision" the DB
Allows track/rollback schema changes
6. Current Status
No hard dependencies on Grails 1.4
Everything available as plugins today
Both main features developed by Burt Beckwith
7. Current Status
No hard dependencies on Grails 1.4
Everything available as plugins today
Both main features developed by Burt Beckwith
H2 plugin or JAR dependency
com.h2database:h2:1.2.147
8. Current Status
No hard dependencies on Grails 1.4
Everything available as plugins today
Both main features developed by Burt Beckwith
H2 plugin or JAR dependency
com.h2database:h2:1.2.147
Reverse Engineering
http://grails-plugins.github.com/grails-db-reverse-engineer/
grails install-plugin db-reverse-engineer
latest version 0.3
9. Current Status
No hard dependencies on Grails 1.4
Everything available as plugins today
Both main features developed by Burt Beckwith
H2 plugin or JAR dependency
com.h2database:h2:1.2.147
Reverse Engineering
http://grails-plugins.github.com/grails-db-reverse-engineer/
grails install-plugin db-reverse-engineer
latest version 0.3
Database Migrations
http://grails-plugins.github.com/grails-database-migration/
grails install-plugin database-migration
latest version 0.2
11. H2 in Grails 1.4
Replaces HSQLDB
support in-memory, file-based, clustered DB
comes with a build-in web console
http://localhost:8080/appname/dbconsole
Available as (insecure) plugin today
14. Reverse Engineering
Existing DB + Grails command = GORM classes
Uses DB connection from DataSource.groovy
Configuration in grails-app/conf/Config.groovy
Started with grails db-reverse-engineer
15. Reverse Engineering
Existing DB + Grails command = GORM classes
Uses DB connection from DataSource.groovy
Configuration in grails-app/conf/Config.groovy
Started with grails db-reverse-engineer
Detailed configuration available
covers many-to-many relations
include/exclude tables, columns etc.
Creates belongsTo, hasMany and constraints
Simplest configuration:
grails.plugin.reveng.packageName = com.acme.db
17. The good and the bad
Recognizes length limitations & constraints
Creates relates between entities
Even handles composite primary keys
18. The good and the bad
Recognizes length limitations & constraints
Creates relates between entities
Even handles composite primary keys
Careful: Will probably not get it 100% correct!
Always review generated classes
19. The good and the bad
Recognizes length limitations & constraints
Creates relates between entities
Even handles composite primary keys
Careful: Will probably not get it 100% correct!
Always review generated classes
Still helps to save a lot of work
27. Database Migrations
Liquibase: verbose XML schema changesets
Plugin: Groovy changesets & automation
Two options
track changes manually (changeset first)
create automatic diffs (GORM first)
Allows to track schema changes in VCS
Create DB from scratch
Apply/rollback incremental changes
28. Database Migrations
Liquibase: verbose XML schema changesets
Plugin: Groovy changesets & automation
Two options
track changes manually (changeset first)
create automatic diffs (GORM first)
Allows to track schema changes in VCS
Create DB from scratch
Apply/rollback incremental changes
Possibilities:
Simplifies development with changing DB
Manage updates to production DB
30. Issues to watch out for
BACKUP your database!
Always review automatic changesets!
31. Issues to watch out for
BACKUP your database!
Always review automatic changesets!
Indexes, triggers etc. might be missed
Checksum errors
Changes tracked by filename in
grails-app/conf/migrations/xxxx.groovy
It doesn't like changeset changes
32. Summary
New goodies before Grails 1.4 release
Lots of automation when working with databases
Reverse Engineering simplifies app setup
Best practice: Version your DB