Reputation: 4607
I have a project that I am working on for school that is using hibernate for the jpa implementation. My question is, if inside of the hibernate properties file I turn off the schema generation, and I want to update the schema manually (my ddl file) and have my schema be deployed with the application, what do I need to include in my <build></build>
tag to have the schema as part of what gets deployed?
Under src/main/resources I have a ddl directory that contains the table creation script.
Upvotes: 0
Views: 101
Reputation: 240996
You will need to use sql-maven-plugin to execute sql during build process
something like
<build>
[...]
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sql-maven-plugin</artifactId>
<version>1.5</version>
<dependencies>
<!-- specify the dependent jdbc driver here -->
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>8.1-407.jdbc3</version>
</dependency>
</dependencies>
<!-- common configuration shared by all executions -->
<configuration>
<driver>org.postgresql.Driver</driver>
<url>jdbc:postgressql://localhost:5432:yourdb</url>
<username>postgres</username>
<password>password</password>
<!-- You can comment out username/password configurations and
have maven to look them up in your settings.xml using ${settingsKey}
-->
<settingsKey>sensibleKey</settingsKey>
<!--all executions are ignored if -Dmaven.test.skip=true-->
<skip>${maven.test.skip}</skip>
</configuration>
<executions>
<execution>
<id>create-data</id>
<phase>process-test-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<orderFile>ascending</orderFile>
<fileset>
<basedir>${basedir}</basedir>
<includes>
<include>src/test/sql/test-data2.sql</include>
</includes>
</fileset>
</configuration>
</execution>
</plugin>
[...]
</plugins>
[...]
</build>
change configuration based on your DB
Upvotes: 1