Using Gorm outside of Grails (GORM)
Introduction
Currently it is possible, though with a bit of effort, to utilize Gorm - complete with dynamic methods - independent (mostly) of the rest of the Grails framework.
It is hoped this page can be used as a reference point from which we can eventually package and maintain Gorm externally from Grails.
Instructions
Download the gorm-<version>.zip ZIP attachment.
Unzip, look at the README.txt, have fun.
TODO
Plenty.
Here's just a quick run-down of ideas; these will certainly need to be edited by those more knowledgeable.
- it should actually share code in a more generic fashion; which would be much better than needing to basically cut'n'paste stuff from all over with every new release of grails. Maybe a HibernateGormPlugin which could share code w/ HibernateGrailsPlugin and/or a lighter-weight version of AbstractGrailsPluginManager could be packaged up in a 'gorm-version.jar' ( vs. grails-gorm-version.jar ) along with the rest of the dependencies listed above.
- would seem better for it to read the domain classes from .../domain, or .../gorm/domain - rather than .../grails-app/domain as it does now. There should be no user-visible reference to grails.
- would be great if it was packaged in a similar manner to grails: with a few ant targets via gant and whatnot: i.e., gorm create-app, would create the necessary directory structure to get started, gorm run <arg> could run a specific script/class, gorm console/shell, gorm create-unit-test, etc. etc.
- the ultimate goal - if we could at some point have an official gorm package/jar that could be downloaded straight from grails.org or codehaus.org, which would be maintained along with the latest grails-gorm release.
Notes
The work done was orginally taken from the efforts of jweldin, who posted the original code on his blog a while back: http://jweldin.com/blog/?p=6
The README.txt
#0: you can start off with the test that's included, just do:
ant run -Drun=GormTest
Now for the instructions:
#1: modify ./hibernate.properties appropriately for your environment
#2: put your jdbc driver into ./lib
#3: put your gorm domain classes into ./grails-app/domain
#4: put the scripts you want to run into ./grails-app/scripts
#5: you have three ant targets: run, build, and clean
#6: execute the script you want with:
ant run -Drun=YourScript
Further Exploration: Java on GORM
John McClean has written a multi-part tutorial for taking advantage of GORM functionality from within Java.

