How to manage many schemas on one database using hibernate

南笙酒味 提交于 2019-12-24 03:34:33

问题


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.



来源:https://stackoverflow.com/questions/4158820/how-to-manage-many-schemas-on-one-database-using-hibernate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!