小编oko*_*kor的帖子

使用 spring 数据 jpa 在存储过程中读取引用游标作为输出参数返回 null

我正在尝试使用 spring 数据 jpa 和 spring 引导读取 oracle 存储过程中的 refcursor,该存储过程成功运行,但对返回的 List 的引用始终为空。

我尝试使用 Hibernate 作为 JPA 提供程序和 Eclipse Link 没有成功,下面是 oracle ddl 和 java 代码

Oracle 表(我用一些示例数据填充了该表)

CREATE TABLE role
    (id                             NUMBER(10,0),
    name                           VARCHAR2(255 CHAR))
Run Code Online (Sandbox Code Playgroud)

Oracle 存储过程

PROCEDURE collect_roles (role_list_o OUT SYS_REFCURSOR) IS
    ex EXCEPTION;
BEGIN
    OPEN role_list_o FOR SELECT id, name FROM role;
END;
Run Code Online (Sandbox Code Playgroud)

pom.xml(oracle jdbc 驱动依赖是从本地 ojdbc7.jar 安装在 maven 中的)

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
    http://maven.apache.org/maven-v4_0_0.xsd"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>

<groupId>org.springframework</groupId>
<artifactId>gridapp</artifactId>
<version>0.1.0</version>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.5.RELEASE</version>
</parent>


<properties> …
Run Code Online (Sandbox Code Playgroud)

jpa sys-refcursor spring-data-jpa spring-boot

6
推荐指数
1
解决办法
4310
查看次数

标签 统计

jpa ×1

spring-boot ×1

spring-data-jpa ×1

sys-refcursor ×1