【问题标题】:How to map different queries for different database in one project in springboot?如何在spring boot中为一个项目中的不同数据库映射不同的查询?
【发布时间】:2020-08-25 21:51:18
【问题描述】:

在我当前的项目中,我正在从 Oracle 迁移到 Azure SQL Server。现在,我们需要将两个数据库集成到相同的查询中。根据我的配置,项目将连接 Oracle 或 Azure SQL。

问题是,有一些查询不兼容这两种数据库类型。例如,nextval 适用于 Oracle,但不适用于 Azure SQL:

在甲骨文中:

... values(unique_id_seq.nextval ...

在 Azure SQL 中:

... values(NEXT VALUE FOR unique_id_seq, ...

因此,我认为我需要创建两个不同的查询,并且我的项目应该知道我正在加载哪个数据库,并且它应该映射到正确的查询。这可以在springboot中实现吗?我对springboot很陌生..

(我的一位同事说If possible try to convert query into HQL or add the mapping entity, instead of creating separate queries.,但我不确定这是什么意思。)

【问题讨论】:

    标签: java database oracle azure spring-boot


    【解决方案1】:

    尝试将 Spring Boot 与 Hibernate 结合使用。

    【讨论】:

      猜你喜欢
      • 2012-05-17
      • 2010-11-21
      • 2016-01-13
      • 2022-10-23
      • 1970-01-01
      • 1970-01-01
      • 2021-09-03
      • 1970-01-01
      • 2019-10-28
      相关资源
      最近更新 更多