I have one database that has many schemas, one per client. We want to create a web application to be access online by the clients, the application should get the schema on runtime, I think in use Springframework
and Hibernate
to access the database. It's possible to use hibernate to make this works? Exist another framework for this?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Hibernate gets all JDBC connections from a connection factory, and this connection factory settings determine the DB schema against which all Hibernate queries/updates are issued. You can configure your application with multiple SessionFactory
instances, each with a connection factory pointing to a different database schema. Then at runtime, you can pick one the appropriate SessionFactory
to work with.
A simpler solution would be to run multiple copies of your web application, one for each client.