These properties will generate a script called schema.sql that will create the schema for an HSQL database. It will also load that schema with data from a file called data.sql. Note that data.sql needs to be on the classpath.
jpaProperties.put(Environment.HBM2DDL_AUTO, "create");
jpaProperties.put(Environment.HBM2DDL_IMPORT_FILES, "data.sql");
jpaProperties.put("javax.persistence.schema-generation.create-database-schemas", "true");
jpaProperties.put("javax.persistence.schema-generation.scripts.action", "create");
jpaProperties.put("javax.persistence.schema-generation.scripts.create-target",
"src/test/resources/schema.sql");
jpaProperties.put("javax.persistence.database-product-name", "HSQL");
See the complete Java configuration on github here. It uses Spring framework, Spring-data-jpa, and Hibernate.
No comments:
Post a Comment