Play framework is an opensource framework whose aims is to maximize the development efficiency of JEE developers.

MinuteProject 4 Play aims at generating PlayFramework application compliant artifacts from an enriched database schema.
The reader can find a MP 4 Play 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 Play web application.
It also generates Play REST WS (xml, json) interface and also a jQuery sample client.


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


Play must be available in the system path.
Download MinuteProjectlast version.
MP_HOME environment variable must point to the MinuteProject package directory.

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 Play target
  5. Click generate

Via the configuration file
An example can be found <MP_HOME>/demo/config/mp-config-play-last-features.xml
On the configuration file below 2 enrichment features are of interest for tuning Play compliant artifacts:
<entity name="SELLERCONTACTINFO" alias="SELLER">
The controller name will be based on the table alias
<field name="EMAIL">
    <stereotype stereotype="EMAIL"> </stereotype>
Adding the stereotype 'EMAIL' will be used for Play validation annotations.
<!DOCTYPE root>
    <configuration name="petshop">
        <model name="petshop" version="1.0" package-root="">
                <driver name="hsqldb" version="" groupId="hsqldb" artifactId="hsqldb"></driver>
                <!-- for Oracle and DB2 please set the schema
                <schema> </schema>
                <primaryKeyPolicy oneGlobal="true" oneForEachTable="false">
                    <primaryKeyPolicyPattern prefix="" suffix="" name="sequencePattern"
                    <condition type="exclude" startsWith="DUAL"></condition>
                    <condition type="exclude" startsWith="ID_GEN"></condition>
                <business-package default="">
                   <entity name="CATEGORY" content-type="reference-data" >
                         <sql-path path="NAME"/>
                    <entity name="SELLERCONTACTINFO" alias="SELLER">
                    <field name="EMAIL">
                             <stereotype stereotype="EMAIL"> </stereotype>
        <targets catalog-entry="Play">
On <MP_HOME>/demo/config

Step 2: All the rest

  1. Go to the generated code root directory
  2. Execute build-<model-name>.(cmd/sh)
    1. It create a Play project
    2. Copy the generated artifacts
    3. Copy the jdbc lib
    4. Starts Play server
  3. Open a browser at http://localhost:9000/admin
  4. Testing your grails REST Backend access. More information can be find on the REST track.
    1. Directly
      1. http://localhost:8080/rest/xml/<entity plurialized>/<primary key> for xml format
      2. http://localhost:8080/rest/xml/<entity plurialized>/<primary key> for json format
    2. Via jQuery Test Client
      1. http://localhost:8080/rest/client/xml/<entity plurialized> for xml format
      2. http://localhost:8080/rest/client/xml/<entity plurialized> for json format

Generated artifacts

MP generates the following artifacts
  • 'Play' model (JPA + Play specific annotations)
  • Associated JPA2 metamodel.
  • controllers extended to handle REST xml, json return format for simple search query
  • jQuery Client application for searching and displaying each entities
  • views for
    • xml, json messages
    • html jQuery client
  • config:
    • routes (standard and REST)
    • application.conf
  • misc cmd/bash scripts


Petshop DB is Reverse engineered into a play 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 'Play'
        8. Click on 'Generate'
        9. => the generated code will go in <MP_HOME>/output/petshop/Play
      2. Via scripts
        1. in /demo/config execute demo-last-features-play.(cmd/sh)
        2. => the generated code will go in <MP_HOME>/demo/output/play

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:9000/admin 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:9000/rest/xml/addresses/1
      2. Ex for Address entity with json and pk=1 http://localhost:9000/rest/json/addresses/1
    2. Via a jQuery Html page
      1. Ex for Address entity with xml http://localhost:9000/rest/client/xml/addresses
      2. Ex for Address entity with json http://localhost:9000/rest/client/json/addresses

Web Navigation

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


At the Url: http://localhost:9000/admin
The naming convention for controller is to plurialize the entity name. If the database entity name is 'cryptic', the user can enrich it with an alias that would served as based for the controller name.

Items CRUD operations

Items admin screen at http://localhost:9000/admin/items

Address Update (Edit) Screen at http://localhost:9000/admin/items/1


Example of customs validation for email.
Enriching a field in MP configuration with the stereotype 'email' trigger the generation of the associated Play validation annotation.