title: Spring & JPA: Create database schema and tables on demand
body: <p>Is there any possibility in JPA/Spring to create/delete a database schema with a custom name and according tables (given by @Entity annotations) at runtime, e.g. when the user presses a button?</p>
  
  <p>I only know about the <code>javax.persistence.schema-generation</code> properties, which are executed at startup of my application and use a predefined schema name.</p>
  
  <p>A short (and simplified) example of what I am looking for: </p>
  
  <p>Let's say I have two entities, <code>Dog</code> and <code>Cat</code>. When the user presses a button, a new schema <code>animals1</code> with two tables <code>Dog</code> and <code>Cat</code> is created. All queries now go to schema <code>animals1</code>. When the user presses the button a second time, a different schema <code>animals2</code> with the two tables is created, and all queries now go to <code>animals2</code>.</p>
  
  <p>I assume there is some magic I can do in Spring, but I have no clue where to start. I would be grateful for any hints.</p>