You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Spring Boot 3.4.0 集成Oracle方言分页异常及Oracle12cDialect类找不到问题求助

Spring Boot 3.4.0 集成Oracle方言分页异常及Oracle12cDialect类找不到问题求助

各位好,我在基于Spring Boot 3.4.0(Java 17)开发的项目中集成Oracle数据库,使用Spring Data JPA的分页功能时遇到了两个棘手的问题,想请教大家帮忙排查:

问题1:使用OracleDialect时的分页执行异常

我的配置中指定了Oracle方言:

database-platform: org.hibernate.dialect.OracleDialect

执行如下分页代码时:

Pageable pageable = PageRequest.of(page, size);
Page<Rate> rates = rateRepository.findAll(pageable);

Postman返回了数据访问异常:

org.springframework.dao.InvalidDataAccessResourceUsageException: JDBC exception executing SQL

问题2:尝试使用Oracle12cDialect时的两类异常

2.1 类找不到异常

当我尝试将方言换成Oracle12cDialect时,直接启动项目就报类找不到的错误。

2.2 SQL语法错误(ORA-00933)

后续调整后虽然类找到了,但执行同样的分页代码:

Pageable pageable = PageRequest.of(page, size);
Page<Rate> rates = rateRepository.findAll(pageable);

Postman返回了更具体的SQL语法异常:

org.springframework.dao.InvalidDataAccessResourceUsageException: JDBC exception executing SQL [select r1_0.rate_id,r1_0.comments,r1_0.created_at,r1_0.rating_star,r1_0.remote_address,r1_0.updated_at from ms_web_rate r1_0 offset ? rows fetch first ? rows only] [ORA-00933: SQL command not properly ended\n\r\nhttps://docs.oracle.com/error-help/db/ora-00933/] [n/a]; SQL [n/a]"

从异常可以看到Hibernate生成了使用offset ... fetch first ... only语法的SQL,但Oracle返回了ORA-00933(SQL命令未正确结束)的错误。

有没有朋友遇到过类似的问题?或者能帮我分析下这两个问题的根因和解决办法吗?


备注:内容来源于stack exchange,提问作者Ilyas Azizzade

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.14 09:59:37