Process of changing table/model structure:
- Create sql script that do what you want
- Update entities
- Update database with Flyway mechanism
- Update meta models (Query Meta Model, Write Meta Model) by QueryDSL maven plugin
Dependencies:
- Flyway - is used as database migration tool.
- Hibernate - is used as ORM in write stack.
- QueryDSL - is used as a tool for type safe SQL-like queries.
Uses Hibernate and jpa-querydsl.
Uses sql-querydsl with spring-jdbc-extension.
In brief, to synchroznize database with flyway sql scripts and meta models with database, just run:
mvn -Pdb-tools compile
-
After project is deployed on server, database is automatically initialized and upgreaded. There is no need to use command tool.
-
If you want to manually upgread the database. Use command tool:
mvn -Pdb-tools initialize flyway:init mvn -Pdb-tools initialize flyway:migrate
Query meta model is generated from tables from database. It is is generated to src/main/java location, so there is no need to generate automatically by IDE or to generate it during integration tests on hudson.
mvn -Pdb-tools initialize com.mysema.querydsl:querydsl-maven-plugin:export
Command Meta Model is generated from JPA entities. It is automatically generated during compile phase to target/generated-sources/querydsljpa directory.
mvn compile