将 Spring Boot 3.2.0 升级到 3.2.1 后查询执行错误 - ORA-00933 - 命令未正确结束

问题描述 投票:0回答:1

我有一个带有大量查询的 Java Spring 应用程序,到目前为止一直有效,直到 spring boot 3.2.0

最近,简单地更改为 spring boot 3.2.1 后,我开始收到这种错误:

org.springframework.dao.InvalidDataAccessResourceUsageException: JDBC exception executing SQL [select o1_0.org_id,o1_0.cct,o1_0.cod_org,o1_0.description,o1_0.id,o1_0.name from organizations o1_0 where (? is null or trim(BOTH from ?)='' or lower(o1_0.name) like lower(trim(BOTH from ?))) offset ? rows fetch first ? rows only] [ORA-00933: comando SQL command not properly ended]

我的 pom 依赖项如下所示:

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.2.1</version>
        <relativePath />
    </parent>

    <properties>
        <java.version>21</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>

    <dependencies>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        
        <dependency>
            <groupId>com.oracle.database.jdbc</groupId>
            <artifactId>ojdbc11</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
        </dependency>

    </dependencies>

我的查询,删除了一些我无法透露的代码,但仍然给出错误,条件很简单:

    
    @Query("select org  "
         + "  from Organization         org     "
         + " where 1 = 1 "
         + "   and ( "
         + "         :#{#request.name} is null "
         + "         or "
         + "         trim(:#{#request.name}) = '' "
         + "         or "
         + "         lower(org.name) like lower(trim(:#{#request.name}))"
         + "       ) "
    )
    Page<Organization> getPageByCriteria(@Param("request") GetOrganizationsRequestDto request, Pageable pageable);

我正在连接到 oracle 数据库版本 11g

有人遇到此类问题或类似问题可以帮助我解决吗?我怀疑这与 ojdbc 自上次 Spring Boot 版本以来没有更新有关。

谢谢

编辑:根据错误日志添加了对数据库执行的纯SQL查询

java spring spring-boot hibernate hql
1个回答
0
投票

从 6.2 开始,Hibernate 团队开始放弃对不受支持的 DB 的支持(请阅读 Hibernate ORM 6.2 - DB 版本支持删除对 19 之前的 Oracle 版本的支持删除对 11.2 之前的 Oracle 版本的支持),但是,其中一些数据库仍然(部分)通过

hibernate-community-dialects
模块支持。您需要将
hibernate-community-dialects
依赖项添加到您的项目中:

<dependency>
  <groupId>org.hibernate.orm</groupId>
  <artifactId>hibernate-community-dialects</artifactId>
</dependency>

并且最有可能将

spring.jpa.properties.hibernate.dialect
设置为
Oracle10g
 中的 
application.properties

© www.soinside.com 2019 - 2024. All rights reserved.