Grails is an opensource framework of springsource that encourages RAD approach.

MinuteProject 4 Grails aims at generating Grails application compliant artifacts from an enriched database schema.
Grails also provides a reverse engineering plugin illustrated at grails site.
The reader can find a MP 4 Grails demo for Petshop in the latest demo-src-generated-<version>.zip package.

The goal of this page is to show how to quickly reverse-engineer a model to produce a Grails web application.
It also generates grails REST WS (xml, json) interface will be generated with a jQuery sample client. Additional information on the MinuteProject 4 REST track is available here.


Two steps are needed:
  1. The first 'Generation step' consists of configuring MP kernel either via a configuration file or via the console.
  2. The second step 'All the rest' consists of running a script (generated at step 1) that does the packaging and deployment of the generated application


Grails must be available in the system path.
Download MinuteProjectlast version.
MP_HOME environment variable must point to the MinuteProject package directory.
Check that your database connection is available

Step 1: Generation

Via the console
  1. Start the MP console(<MP_HOME>/bin/start-console.(cmd/sh). How to use the console.
  2. Fill the connection information to the datamodel
  3. Fill the model general information (model, package names, version primary key policy, scope).
  4. Choose Grails target
  5. Click generate

Via the configuration file
An example can be found <MP_HOME>/demo/config/mp-config-grails-last-features.xml.
To run it: execute demo-last-features-grails.(cmd/sh)

Step 2: All the rest

  1. Go to the generated code root directory
  2. Execute build-<model-name>.(cmd/sh)
    1. It create a Grails project
    2. Copy the generated artifacts
    3. Copy the jdbc lib
      1. Remark: this step should be removed since MP is also generating the driver dependency at runtime, but some driver are not found...
    4. Starts Grails run-app
  3. Open a browser at http://localhost:8080/<model-name>
  4. Testing your grails REST Backend access. More information can be find on the REST track.
    1. Directly
      1. http://localhost:8080/<model-name>/rest/xml/<entity plurialized>/<primary key> for xml format
      2. http://localhost:8080/<model-name>/rest/xml/<entity plurialized>/<primary key> for json format
    2. Via jQuery Test Client
      1. http://localhost:8080/<model-name>/rest/client/xml/<entity plurialized> for xml format
      2. http://localhost:8080/<model-name>/rest/client/xml/<entity plurialized> for json format

Alternately since Grails provides also a reverse-engineering facility MP generate the scripts to use it
  1. Go to the generated code root directory
  2. Execute execute-grails-plugin-reverse-4-<model-name>.(cmd/sh)
    1. The generated dependencies for the jdbc driver are commented (Some DB driver are not found in the repository). So please uncomment it if correct.

Generated artifacts

MP generates the following artifacts
  • gorm groovy files
  • controllers extended to handle REST xml, json return format for simple search query
  • Rest UrlMapping routes
  • jQuery Client application for searching and displaying each entities
  • config: DataSource.groovy and BuildConfig.groovy
  • misc cmd/bash scripts


  • An entity with a field id which is not a primary key will raise an error
  • Composite pk not supported in first release
  • Many-two-many are generated but commented.


Petshop DB is Reverse engineered into a grails application.
You can obtain the resulting code by:
  1. Downloading it:
    1. The latest demo-src-generated-<version>.zip is on sourceforge
  2. Generating it:
    1. Start the shipped Petshop Hsqldb
      1. in /sample execute start-petshop-database.(bat/sh)
    2. Generate via
      1. Console
        1. in /bin execute start-console.(cmd/sh)
        2. Choose HSQLDB as DB
        3. Fill URL with jdbc:hsqldb:hsql://
        4. Fill username with 'sa'
        5. Fill package with ''
        6. Fill model name with 'petshop'
        7. Select target technology 'Grails'
        8. Click on 'Generate'
        9. => the generated code will go in <MP_HOME>/output/petshop/Grails
      2. Via scripts
        1. in /demo/config execute demo-last-features-grails.(cmd/sh)
        2. => the generated code will go in <MP_HOME>/demo/output/grails

You can run the generated:
  1. Start the shipped Petshop Hsqldb
    1. in /sample execute start-petshop-database.(bat/sh)
  2. Executing the resulting script
    1. in your generated code direct execute build-<model-name>.(cmd/sh) here build-petshop.(cmd/sh)

You can view the result:
  1. By testing the web application http://localhost:8080/petshop/ that leads you to a menu. Below is the experience you can get.
  2. By testing the REST client application
    1. Directly
      1. Ex for Address entity with xml and pk=1 http://localhost:8080/petshop/rest/xml/addresses/1
      2. Ex for Address entity with json and pk=1 http://localhost:8080/petshop/rest/json/addresses/1
    2. Via a jQuery Html page
      1. Ex for Address entity with xml http://localhost:8080/petshop/rest/client/xml/addresses
      2. Ex for Address entity with json http://localhost:8080/petshop/rest/client/json/addresses

Web Navigation

Here are some UC directly available on top of Petshop database.

View Item list


Create Seller contact info

Creation result

Create Seller contact info

Edition screen

Add item

Check validation by submitting an empty form (i18n in french)

Fill a form
Add item done