Devskiller / jpa2ddl

JPA Schema Generator Plugin
Apache License 2.0
110 stars 33 forks source link

Not generating schema #23

Closed lopezm94 closed 3 years ago

lopezm94 commented 6 years ago

I added the plugin to pom.xml with the following configuration:

<build>
    <sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
    <testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
    <plugins>
        <plugin>
            <groupId>com.devskiller.jpa2ddl</groupId>
            <artifactId>jpa2ddl-maven-plugin</artifactId>
            <version>0.9.12</version>
            <extensions>true</extensions> <!-- required to run automatically -->
            <configuration>
                <outputPath>${project.basedir}/src/main/resources/db/migration/database.sql</outputPath>
                <packages>
                    <package>com.registry.model</package>
                </packages>
                <jpaProperties>
                    <property>
                        <name>hibernate.dialect</name>
                        <value>org.hibernate.dialect.MySQL57Dialect</value>
                    </property>
                    <property>
                        <name>hibernate.default_schema</name>
                        <value>prod</value>
                    </property>
                </jpaProperties>
                <formatOutput>true</formatOutput>
                <skipSequences>true</skipSequences>
                <delimiter>;</delimiter>
                <action>DROP_AND_CREATE</action> <!--DROP, , CREATE, DROP_AND_CREATE, or UPDATE-->
            </configuration>
        </plugin>
               .
               .
               .
    </plugins>
</build>

After that I ran both ./mvnw com.devskiller.jpa2ddl:jpa2ddl-maven-plugin:0.9.12:generate -X -f pom.xml and ./mvnw com.devskiller.jpa2ddl:jpa2ddl-maven-plugin:0.9.12:generate. It didn't generate the .sql files at the outputPath and the only message appearing in the terminal was:

/home/juan/Projects/registry

I tried running with the intelliJ maven plugin afterwards and got a bit more verbose output:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building registry 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- jpa2ddl-maven-plugin:0.9.12:generate (default-cli) @ registry ---
[INFO] Running schema generation...
[INFO] HHH000412: Hibernate Core {5.2.10.Final}
[INFO] HHH000206: hibernate.properties not found
[INFO] HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
[WARNING] HHH10001002: Using Hibernate built-in connection pool (not for production use!)
[INFO] HHH10001005: using driver [null] at URL [jdbc:h2:mem:jpa2ddl;MODE=MYSQL]
[INFO] HHH10001001: Connection properties: {password=****, user=sa}
[INFO] HHH10001003: Autocommit mode: false
[INFO] HHH000115: Hibernate connection pool size: 20 (min=1)
[INFO] HHH000400: Using dialect: org.hibernate.dialect.MySQL57Dialect
[INFO] HV000001: Hibernate Validator 5.3.6.Final
[INFO] HHH000476: Executing import script 'org.hibernate.tool.schema.internal.exec.ScriptSourceInputNonExistentImpl@198536f6'
[INFO] HHH10001008: Cleaning up connection pool [jdbc:h2:mem:jpa2ddl;MODE=MYSQL]
[INFO] Schema saved to /home/juan/Projects/registry/src/main/resources/db/migration/database.sql
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.130 s
[INFO] Finished at: 2018-06-19T12:51:01+02:00
[INFO] Final Memory: 21M/74M
[INFO] ------------------------------------------------------------------------

Process finished with exit code 0

Any idea what could be happening?

jkubrynski commented 5 years ago

Is it still a problem?

Nomad95 commented 5 years ago

@jkubrynski I have the same problem with similar configuration. The build even removes file if it exists in outputPath

Nomad95 commented 5 years ago

OK. I managed to generate the sql. I've described the plugin in parent (pluginManagement) and child poms and then running clean install on parent. But embedded h2 db cant generate update scripts because i have JSON type in my Postgresql db ;/

jkubrynski commented 3 years ago

Primary issue is resolved. The JSON type will be possible after closing #40