divinespear / jpa-schema-maven-plugin

Maven plugin for generate database schema or DDL scripts from JPA entities
http://divinespear.github.io/jpa-schema-maven-plugin
Apache License 2.0
21 stars 19 forks source link

jpa-schema-maven-plugin

Build Status FOSSA Status

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.

Before Announce...

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.

Announce 0.2

Finally, I got some times, and 0.2 is here.

On 0.2.x, plugin required

Unfortunately, DataNucleus does not support on maven plugin... but I will find a way. I always have.

How-to Use

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.

Database Product Names

It's about databaseProductName property. If not listed below, will work as basic standard SQL.

for EclipseLink

databaseMajorVersion and databaseMinorVersion is not required.

for Hibernate

Some products uses different dialect by databaseMajorVersion and/or databaseMinorVersion. You can override using hibernate.dialect property.

License

Source Copyright © 2013 Sin-young "Divinespear" Kang. Distributed under the Apache License, Version 2.0.

FOSSA Status