java - Spring & JPA: Create database schema and tables on demand -


is there possibility in jpa/spring create/delete database schema custom name , according tables (given @entity annotations) @ runtime, e.g. when user presses button?

i know javax.persistence.schema-generation properties, executed @ startup of application , use predefined schema name.

a short (and simplified) example of looking for:

let's have 2 entities, dog , cat. when user presses button, new schema animals1 2 tables dog , cat created. queries go schema animals1. when user presses button second time, different schema animals2 2 tables created, , queries go animals2.

i assume there magic can in spring, have no clue start. grateful hints.

there api "generateschema" in jpa:

http://docs.oracle.com/javaee/7/api/javax/persistence/persistence.html#generateschema-java.lang.string-java.util.map-

check blog entry https://antoniogoncalves.org/2014/12/11/generating-database-schemas-with-jpa-2-1/


Comments