简体   繁体   English

Spring Data JPA 应用调用 Oracle 包程序出现 PLS-00201 错误

[英]Spring Data JPA app calling Oracle package procedure rises PLS-00201 error

I'm trying to make a simple Spring Boot application (using STS 4) that returns some data from an Oracle 19c database.我正在尝试制作一个简单的 Spring Boot 应用程序(使用 STS 4),它从 Oracle 19c 数据库返回一些数据。 My application uses an annotation-based configuration and accesses only the schema defined in the application.properties file.我的应用程序使用基于注释的配置,并且仅访问在 application.properties 文件中定义的模式。 All works fine until I use simple @Entity classes, but now I'm trying to call a simple procedure defined in a package.在我使用简单的@Entity 类之前一切正常,但现在我试图调用一个在包中定义的简单过程。 The procedure is public, the package has a synonym (even if the schema is always the same) and all the grants:该过程是公开的,包具有同义词(即使模式始终相同)和所有授权:

create or replace package body let_mock is

  function sumfun(p_a In Integer, p_b In Integer) return Integer Is
  Begin
    Return p_a + p_b;
  End;

  Procedure sumproc(p_a In Integer, p_b In Integer, po_res Out Integer) Is
  Begin
    po_res := p_a + p_b;
  End;

end let_mock;

to keep things as simple as possible, I defined the stored procedure call in an Entity class that maps a table为了使事情尽可能简单,我在映射表的实体类中定义了存储过程调用

@Entity
@NamedStoredProcedureQuery(name = "SumProc", procedureName = "let_mock.sumproc", 
parameters = {
        @StoredProcedureParameter(mode = ParameterMode.IN, name = "p_a", type = Integer.class),
        @StoredProcedureParameter(mode = ParameterMode.IN, name = "p_b", type = Integer.class),
        @StoredProcedureParameter(mode = ParameterMode.OUT, name = "po_res", type = Integer.class) })


@Table(name = TestataLetture.TABLE_NAME)
public class TestataLetture {
    public static final String TABLE_NAME= "LET_TESTATE_LETTURE";
    @Id
    @Column(name = "tele_testata_lettura_id")
    private String lettura_id;

then I mapped the procedure in the Repository interface然后我在存储库界面中映射了该过程

public interface RepoLetture extends JpaRepository<TestataLetture, String> {
    @Procedure(name = "SumProc")
    public int getSum(@Param("p_a") Integer a, @Param("p_b") Integer b);
}

but when I call getSum() it always ends up with this error但是当我调用 getSum() 它总是以这个错误结束

Hibernate: 
    {call let_mock.sumproc(?,?,?)}
2022-06-14 23:16:06.395  WARN 28180 --- [nio-8080-exec-1] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 6550, SQLState: 65000
2022-06-14 23:16:06.396 ERROR 28180 --- [nio-8080-exec-1] o.h.engine.jdbc.spi.SqlExceptionHelper   : ORA-06550: row 1, column 7:
PLS-00201: identifier 'LET_MOCK.SUMPROC' must be declared
ORA-06550: row 1, column 7:
PL/SQL: Statement ignored

I've tried many changes (adding schema to names, changing parameters name and type and so on) with no results, it seems to me that Hibernate cannot resolve the procedure name if it belongs to a package.我已经尝试了很多更改(将模式添加到名称、更改参数名称和类型等)但没有结果,在我看来 Hibernate 无法解析属于包的过程名称。 Same error for the package function sumfun().包函数 sumfun() 的错误相同。 Maybe it works if I wrap it in a dummy "from dual" query, but I don't think it's the right way of doing things.如果我将它包装在一个虚拟的“来自双重”查询中,也许它会起作用,但我认为这不是正确的做事方式。

Any help will be appreciated任何帮助将不胜感激

EDIT: I've changed编辑:我改变了

public int getSum(@Param("p_a") Integer a, @Param("p_b") Integer b);

to

public int getSum(@Param("p_a") int a, @Param("p_b") int b);

with no results没有结果

try尝试

@Entity
    @Table(name="CUST", schema="RECORDS")

or in Oracle maybe a synonym would work或者在 Oracle 中,同义词可能会起作用

having changed the connection properties from已将连接属性从

spring.datasource.url=jdbc:oracle:thin:@161.60.160.21/PDBNRTNRG

to

spring.datasource.url=jdbc:oracle:thin:@161.60.160.81/PDBSVINRG

I solved all problems That is, I was using the wrong db.我解决了所有问题也就是说,我使用了错误的数据库。 They are almost identical, almost.它们几乎是相同的,几乎。 Thanks to anyone who could have spent a minute on this post感谢任何可以在这篇文章上花一分钟的人

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从Java调用执行PLSQL时的PLS-00201 - PLS-00201 when calling executing PLSQL from java PLS-00201:必须声明标识符&#39;GETALLNAMES&#39; - PLS-00201: identifier 'GETALLNAMES' must be declared 春季:JdbcTemplate尝试调用存储的db函数时抛出PLS-00201 - Spring: JdbcTemplate throws a PLS-00201 while trying to call a stored db function 在springboot jpa存储库中调用存储过程时出现错误PLS-00221不是过程或未定义 - getting error PLS-00221 is not a procedure or is undefined when calling a stored procedure in springboot jpa repository Spring Data JPA 调用 Oracle 函数 - Spring Data JPA calling Oracle Function 使用带有布尔 IN 参数的 CallableStatement 在 Java 中调用 Oracle PL/SQL 过程会产生 PLS-00306 oracle 错误: - Calling an Oracle PL/SQL procedure in Java using a CallableStatement with a boolean IN parameter gives an PLS-00306 oracle error: PLS-00201:必须声明标识符“DBMS_SODA_ADMIN.DESCRIBE_COLLECTION” - PLS-00201: identifier 'DBMS_SODA_ADMIN.DESCRIBE_COLLECTION' must be declared 如何在调用存储过程之前刷新Spring Data JPA? - How to flush Spring Data JPA before calling stored procedure? Spring数据jpa调用带有大量参数的存储过程 - Spring data jpa calling stored procedure with lots of parameters Spring Data JPA规范调用 - Spring Data JPA Specifications Calling
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM