SQL 命名查询中的 Hiberate 变量架构名称

发布于 2024-08-30 21:14:34 字数 300 浏览 0 评论 0原文

除了默认模式之外,对于某些 SQL 查询,我需要访问特定模式。问题是该特定模式的名称对于不同的环境是不同的。

经过一番研究后,我发现使用这个 链接 我可以指定变量中的模式名称。如果这是真的,我有以下问题:

  1. 这会适用于命名查询中的 SQL 查询吗?
  2. 如何设置变量名的值?

提前致谢。

Other than default schema, for some SQL queries I need to access a particular schema. The issue is that the name of that particular schema is different for different environments.

After goggling I found that using this link I am able to specify the schema name in variable. If that’s true that I have following questions:

  1. Will that would for SQL queries in the named query?
  2. How to set the value for the variable names?

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

摇划花蜜的午后 2024-09-06 21:14:34
  • 创建一个初始化工厂 bean,它占用两个资源位置,并且在初始化时将使用其中一个资源在另一个资源中执行字符串替换,并将结果存储在临时文件中,该临时文件是工厂 bean 的输出。如果您使用替换语言原始正则表达式,则样式要点。
  • 创建一个 spring 上下文,在其中声明此 bean 的实例,传入一个包含所有命名查询的资源,以及一个将进行字符串替换以提供环境特定版本的查询的资源。
  • 在 spring 上下文中创建 SessionFactoryBean 来初始化 hibernate SessionFactory,将前一个工厂 bean 的结果作为映射资源传递,以便 hibernate 配置获取转换后的查询。
  • Create an initializing factory bean which takes two resource locations and on initialization will use one of the resources to execute string replacement in the other, and store the results in a temp file which is the output of the factory bean. Points for style if you make the replacement language raw regex.
  • Create a spring context where you declare an instance of this bean, passing in a resource with all the named queries and a resource which will do the string replacement to provide the environment specific versions of the queries.
  • In the spring context create your SessionFactoryBean to initialize your hibernate SessionFactory, passing in the results of the previous factory bean as a mapping resource so that the converted queries get picked up by the hibernate config.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文