Maven plugin for generate schema or DDL scripts from JPA entities using JPA 2.1 schema generator. for Gradle, see Gradle Plugin.
Currently support EclipseLink (Reference Implementation) and Hibernate.
READ MY LIP; JPA DDL GENERATOR IS NOT SILVER BULLET
Sometimes (most times exactly :P) JPA will generate weird scripts so you SHOULD modify them properly.
Finally, I got some times, and 0.2 is here.
persistence.xml
(like spring-data, spring-boot, ...) related #142.6.1
5.0.7.Final
properties
property.namingStrategy
and dialect
cause Hibernate 4.x to 5.x is cataclysm. please use properties
instead.On 0.2.x, plugin required
Unfortunately, DataNucleus does not support on maven plugin... but I will find a way. I always have.
Define plugin at your maven pom.xml
file like below.
<project>
...
<build>
<plugins>
<plugin>
<groupId>io.github.divinespear</groupId>
<artifactId>jpa-schema-maven-plugin</artifactId>
<version>0.1.12</version>
<configuration>
...
</configuration>
<executions>
<!-- if you want auto-generate schema on lifecycle. default lifecycle is "process-classes". -->
...
</executions>
<dependencies>
<!-- JDBC driver here (if you don't defined in dependencies) -->
...
</dependencies>
</plugin>
...
</plugins>
</build>
...
</project>
To generate, use goal
mvn jpa-schema:generate
or use default lifecycle
mvn process-classes
To see configuration parameters, see here.
It's about databaseProductName
property. If not listed below, will work as basic standard SQL.
databaseMajorVersion
and databaseMinorVersion
is not required.
Oracle12
= Oracle 12cOracle11
= Oracle 11gOracle10
: Oracle 10gOracle9
: Oracle 9iOracle
: Oracle with default compatibilityMicrosoft SQL Server
DB2
MySQL
PostgreSQL
SQL Anywhere
Sybase SQL Server
Adaptive Server Enterprise
= SybasePointbase
Informix Dynamic Server
Firebird
ingres
Apache Derby
H2
HSQL Database Engine
Some products uses different dialect by databaseMajorVersion
and/or databaseMinorVersion
.
You can override using hibernate.dialect
property.
CUBRID
org.hibernate.dialect.CUBRIDDialect
= all versionHSQL Database Engine
org.hibernate.dialect.HSQLDialect
= all versionH2
org.hibernate.dialect.H2Dialect
= all versionMySQL
org.hibernate.dialect.MySQL5Dialect
= 5.xorg.hibernate.dialect.MySQLDialect
= 4.x or beloworg.hibernate.dialect.MySQLMyISAMDialect
org.hibernate.dialect.MySQLInnoDBDialect
org.hibernate.dialect.MySQL5InnoDBDialect
org.hibernate.dialect.MySQL57InnoDBDialect
PostgreSQL
org.hibernate.dialect.PostgreSQL94Dialect
= 9.4 or aboveorg.hibernate.dialect.PostgreSQL92Dialect
= 9.2 or aboveorg.hibernate.dialect.PostgreSQL9Dialect
= 9.xorg.hibernate.dialect.PostgreSQL82Dialect
= 8.2 or aboveorg.hibernate.dialect.PostgreSQL81Dialect
= 8.1 or belowApache Derby
org.hibernate.dialect.DerbyTenSevenDialect
= 10.7 or aboveorg.hibernate.dialect.DerbyTenSixDialect
= 10.6org.hibernate.dialect.DerbyTenFiveDialect
= 10.5org.hibernate.dialect.DerbyDialect
= 10.4 or belowingres
org.hibernate.dialect.Ingres10Dialect
= 10.xorg.hibernate.dialect.Ingres9Dialect
= 9.2 or aboveorg.hibernate.dialect.IngresDialect
= 9.1 or belowMicrosoft SQL Server
org.hibernate.dialect.SQLServer2012Dialect
= 11.xorg.hibernate.dialect.SQLServer2008Dialect
= 10.xorg.hibernate.dialect.SQLServer2005Dialect
= 9.xorg.hibernate.dialect.SQLServerDialect
= 8.x or belowSybase SQL Server
org.hibernate.dialect.SybaseASE15Dialect
= all versionorg.hibernate.dialect.SybaseASE17Dialect
Adaptive Server Enterprise
= SybaseAdaptive Server Anywhere
org.hibernate.dialect.SybaseAnywhereDialect
= all versionInformix Dynamic Server
org.hibernate.dialect.InformixDialect
= all versionDB2 UDB for AS/390
org.hibernate.dialect.DB2390Dialect
DB2 UDB for AS/400
org.hibernate.dialect.DB2400Dialect
= all versionDB2/
org.hibernate.dialect.DB2Dialect
= all versionOracle
org.hibernate.dialect.Oracle12cDialect
= 12.xorg.hibernate.dialect.Oracle10gDialect
= 11.x, 10.xorg.hibernate.dialect.Oracle9iDialect
= 9.xorg.hibernate.dialect.Oracle8iDialect
= 8.x or belowFirebird
org.hibernate.dialect.FirebirdDialect
= all versionSource Copyright © 2013 Sin-young "Divinespear" Kang. Distributed under the Apache License, Version 2.0.