Skip to content

Instantly share code, notes, and snippets.

@entrofi
Last active June 4, 2021 12:57
Show Gist options
  • Save entrofi/47de130941a92665a708ce4f9b25ab38 to your computer and use it in GitHub Desktop.
Save entrofi/47de130941a92665a708ce4f9b25ab38 to your computer and use it in GitHub Desktop.
JPA Export DDL
@Bean(name = JPA_PROPERTIES_BEAN_NAME)
public Properties jpaPropertiesUnitTest() {
Properties properties = new Properties();
properties.put(PROPERTY_HIBERNATE_DIALECT, "org.hibernate.dialect.H2Dialect");
properties.put(PROPERTY_HIBERNATE_SHOW_SQL, true);
properties.put(PROPERTY_HIBERNATE_FROMAT_SQL, true);
properties.put(PROPERTY_HIBERNATE_DDL, VALUE_HIBERNATE_DDL_UPDATE);
properties.put(PROPERTY_HIBERNATE_NAMING_STRATEGY, VALUE_HIBERNATE_DEFAULT_NAMING_STRATEGY);
properties.put(PROPERTY_HIBERNATE_CONNECTION_CHARSET, DEFAULT_CHARSET);
properties.put(PROPERTY_HIBERNATE_LAZY_LOAD, true);
//Export DDL
properties.put("javax.persistence.schema-generation.scripts.action", "drop-and-create");
properties.put("javax.persistence.schema-generation.scripts.create-target", "tiger-schema-create.jpa.ddl");
properties.put("javax.persistence.schema-generation.scripts.drop-target","tiger-schema-drop.jpa.ddl");
return properties;
}
spring.jpa.properties.javax.persistence.schema-generation.scripts.action=drop-and-create
spring.jpa.properties.javax.persistence.schema-generation.scripts.create-target=postgre-schema-create.jpa.ddl
spring.jpa.properties.javax.persistence.schema-generation.scripts.drop-target=postgre-schema-drop.jpa.ddl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment