如何在查询时设置hibernate实体使用的模式名称? [英] How can I set the schema name used by hibernate entities at query time?
问题描述
我们的应用程序使用Hibernate for ORM,并将数据存储在多个模式中,并通过为应用程序定制授权的用户访问它们。
Our application uses Hibernate for ORM, and stores data in several schemas, accessing them with a user whose grants are customized for the application.
模式名称已确定在运行时基于数据;将它们的名字包含在实体映射文件中是不可行的。这意味着我需要一种方法来告诉Hibernate在执行查找时使用特定的模式名称。有没有办法做到这一点?
The schema names are determined at runtime based on data; it's not feasible to include their names in the entity mapping documents. This means that I need a way to tell Hibernate to use a specific schema name when performing lookups. Is there a way to do this?
推荐答案
以下是列出您可以管理的一些方法的页面 Hibernate中的多个模式。我可能会执行自己的连接供应商。您可能也想要禁用缓存。
Here's a page that lists some ways you can manage multiple schemas in Hibernate. I'd probably go with implementing your own connection provider. You'll probably want to disable caching as well.
这篇关于如何在查询时设置hibernate实体使用的模式名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!