This module allows you to export your JPA classes to an SQL script or to import a database tables to POJO instances.
In the /conf/application.conf file, enable the DB module by adding this line:
# The db module
module.db=${play.path}/modules/dbYou can also define a default schema (as in hibernate.default_schema) with :
# Default Schema
db.default.schema=MY_SCHEMAplay db:export myapplicationThis command will create the SQL necessary to create your database. This is extremely usefull if you want to deploy your application in production and you are require to update the database manually.
Be sure to configure correctly your JPA dialect in your /conf/application.conf file.
Generate only the SQL drop clauses
play db:export myapplication --dropGenerate only the SQL create clauses
play db:export myapplication --createSpecify the SQL delimiter
play db:export myapplication --delimiter=;Specify the output file
play db:export myapplication --output=myfile.ddlExport to the database
play db:export myapplication --exportImport extra data to the database (to be use with —export)
play db:export myapplication --import=import.sqlDo not format the SQL.
play db:export myapplication --noformatHalt the export / script generation on the first error
play db:export myapplication --haltonerrorplay db:import myapplicationThis command will create the classes in the models package based on the database tables. This is useful is you have an existing database and you want to re-use this database.
Be sure to configure correctly your database access using your /conf/application.conf file (db.user, db.pass, db.driver, db.url, etc…).
Enables CRUD Controller generation (with the secure-module annotation).
play db:import myapplication --crudDisables POJO generation. Useful if you want to keep the already generated files.
play db:import myapplication --no-pojoEnables reverse engineering customization.
See Hibernate Tools documentation
WARNING: the <table> elements in the reverse engineering file seems to be ignored for POJO and CRUD generation.
<schema-selection>, <type-mapping> and <table-filter> work correctly, though.
play db:import myapplication --reveng=path.to/hibernate.reveng.xml