This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

Spring 3.x JPA2 and drop-create tables : howto?

Aug 26th, 2010, 09:15 PM

What can be used in a spring bean xml configuration file to specify that JPA2 should create the needed tables when it runs? (Like the hibernate "drop-create" or "create") This is running in a JUnit test with memory resident DB (hsqldb AND H2 both are tested separately) Thus the desire is for JPA to create the tables when the db datasource is connected.

An additional desire is to do this:
1. purely in spring configs (see below)
2. preferably with JPA2 only configuration that is neutral to the JPA provider (toplink, hibernate, openjpa etc...) The goal here being no, or minimal, changes to move from one JPA provider to another.

The goal is to keep persistence.xml almost empty and use Spring for all the configuration so that PropertyPlaceHolder's can be used for dynamic configuration and avoiding the need to edit the persistence.xml (or springbeans.xml) inside deployed JAR files. Or worse yet.. A WAR with a JAR with a persistence.xml that would need changing to move from one DB or JPA provider to another.