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.
- Support generate without
persistence.xml
(like spring-data, spring-boot, ...) related #14 - Changed default version of implementations.
- Eclipselink:
2.6.1
- Hibernate:
5.0.7.Final
- Eclipselink:
- Added
properties
property. - Removed properties
namingStrategy
anddialect
cause Hibernate 4.x to 5.x is cataclysm. please useproperties
instead.
On 0.2.x, plugin required
- Java 1.7 or above, and
- Maven 3.3.x. (developed on 3.3.1)
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 version
HSQL Database Engine
org.hibernate.dialect.HSQLDialect
= all version
H2
org.hibernate.dialect.H2Dialect
= all version
MySQL
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 below
Apache 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 below
ingres
org.hibernate.dialect.Ingres10Dialect
= 10.xorg.hibernate.dialect.Ingres9Dialect
= 9.2 or aboveorg.hibernate.dialect.IngresDialect
= 9.1 or below
Microsoft SQL Server
org.hibernate.dialect.SQLServer2012Dialect
= 11.xorg.hibernate.dialect.SQLServer2008Dialect
= 10.xorg.hibernate.dialect.SQLServer2005Dialect
= 9.xorg.hibernate.dialect.SQLServerDialect
= 8.x or below
Sybase SQL Server
org.hibernate.dialect.SybaseASE15Dialect
= all versionorg.hibernate.dialect.SybaseASE17Dialect
Adaptive Server Enterprise
= SybaseAdaptive Server Anywhere
org.hibernate.dialect.SybaseAnywhereDialect
= all version
Informix Dynamic Server
org.hibernate.dialect.InformixDialect
= all version
DB2 UDB for AS/390
org.hibernate.dialect.DB2390Dialect
DB2 UDB for AS/400
org.hibernate.dialect.DB2400Dialect
= all version
- start with
DB2/
org.hibernate.dialect.DB2Dialect
= all version
Oracle
org.hibernate.dialect.Oracle12cDialect
= 12.xorg.hibernate.dialect.Oracle10gDialect
= 11.x, 10.xorg.hibernate.dialect.Oracle9iDialect
= 9.xorg.hibernate.dialect.Oracle8iDialect
= 8.x or below
Firebird
org.hibernate.dialect.FirebirdDialect
= all version
Source Copyright © 2013 Sin-young "Divinespear" Kang. Distributed under the Apache License, Version 2.0.