如何使用Hibernate在一个数据库上管理多个模式 [英] How to manage many schemas on one database using hibernate
问题描述
我有一个数据库有很多模式,每个客户端一个。我们希望创建一个Web应用程序以供客户端在线访问,应用程序应该在运行时获取模式,我认为使用 Springframework
和 Hibernate
来访问数据库。有可能使用休眠来使这个工作?存在另一个框架吗?
Hibernate从连接工厂获取所有JDBC连接,并且此连接工厂设置确定数据库模式所有Hibernate查询/更新都将发布。您可以使用多个 SessionFactory
实例配置您的应用程序,每个实例都有一个连接工厂指向不同的数据库模式。然后在运行时,你可以选择合适的 SessionFactory
来处理。
更简单的解决方案是运行您的Web应用程序的多个副本,每个客户端一个。
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?
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.
这篇关于如何使用Hibernate在一个数据库上管理多个模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!