Skip to content

Instantly share code, notes, and snippets.

@rdemorais
Last active February 8, 2017 18:25
Show Gist options
  • Save rdemorais/978fed5c31da9f527eb76f663e79246b to your computer and use it in GitHub Desktop.
Save rdemorais/978fed5c31da9f527eb76f663e79246b to your computer and use it in GitHub Desktop.
JPA Schema generator
persistence.xml
<property name="javax.persistence.schema-generation.database.action" value="create"/>
<property name="javax.persistence.schema-generation.scripts.action" value="create"/>
<property name="javax.persistence.schema-generation.scripts.create-target" value="create.ddl"/>
<property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver"/>
<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/db"/>
Java class
import javax.persistence.Persistence;
public class CreateSchema {
public static void main(String[] args) {
Persistence.generateSchema("JpaPersistenceUnit", null);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment