Creating runtime databases with Hibernate?

Is it possible to use Hibernate to execute at runtime the creation of a new database (using annotations of model objects as schemas, or from a regular schema file that we define), and then get a connection to this database so that it can be used?

What would we like to do when a certain action occurs (for example, a new user is created), we create a new database for this user (from certain annotations or just a static diagram), and then we have to turn to this database so that the user can write it .

The custom thing is just to illustrate the concept ...

Thank!

+3
source share
4

, , - :

  • , DDL JDBC- - , , hbm2ddl .

  • DataSource SessionFactory DataSource

  • SessionFactory ( ) , SessionFactory .

, , SessionFactory / , , SessionFactory .

+5

b, , ?

, ( - ). ?

+1

, spring .

, : http://blog.springsource.com/2007/01/23/dynamic-datasource-routing/ http://static.springsource.org/ spring/docs/3.0.x/javadoc-api/index.html?org/springframework/aop/target/HotSwappableTargetSource.html

AbstractRoutingDataSource . - , , , , ...

+1

, SAAS , , , .

In sleep mode, filters will help you do this ...

See: http://www.lunatech-research.com/archives/2011/03/04/play-framework-writing-multitenancy-application-hibernate-filters

This is a link for the gaming environment, but it uses hibernate, so you can do almost the same with the classic Java EE stuff ...

+1
source

All Articles