Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring 使用存储库调用存储过程_Spring_Jpa_Stored Procedures - Fatal编程技术网

Spring 使用存储库调用存储过程

Spring 使用存储库调用存储过程,spring,jpa,stored-procedures,Spring,Jpa,Stored Procedures,我试图通过crudepository方法(SpringJPA)调用数据库存储过程 这是我的存储库的代码 public interface TestRepo extends JpaRepository<NewsContainer, Long> { @Procedure(procedureName = "ncMaxVisualisations") public Long getMaxNumberOfVisualisations(); } 测试的输出是 testWithReposit

我试图通过
crudepository
方法(SpringJPA)调用数据库存储过程

这是我的存储库的代码

public interface TestRepo extends JpaRepository<NewsContainer, Long> {

@Procedure(procedureName = "ncMaxVisualisations")
public Long getMaxNumberOfVisualisations(); 
}
测试的输出是

testWithRepository() 
Hibernate: {call ncMaxVisualisations(?)}
  2014-10-24 17:47:28 WARN  SqlExceptionHelper:144 - SQL Error: 0, SQLState: S1009
  2014-10-24 17:47:28 ERROR SqlExceptionHelper:146 - Parameter number 1 is not an OUT    parameter
testWithEM()
Hibernate: {call ncMaxVisualisations()}
  50
若我使用repository调用存储过程,它将等待参数,而若我使用EntityManager调用它,它将正常工作。为什么?

谢谢你的支持

问候。
Mauro

好的,Spring需要一个类型为OUT的参数,它将读取您的输出值

我为此做了一个测试:

程序:

create or replace PROCEDURE TESTPROCEDURE 
(
  TEST1 OUT NUMBER
) AS 
BEGIN
  TEST1 := 50;

END TESTPROCEDURE;
映射:

@Procedure(procedureName = "TESTPROCEDURE", outputParameterName = "TEST1")
public Long callTestProcedure(); 
希望有帮助:)

@Procedure(procedureName = "TESTPROCEDURE", outputParameterName = "TEST1")
public Long callTestProcedure();