Java 将多个@params传递给JPA中的存储过程

Java 将多个@params传递给JPA中的存储过程,java,spring-boot,jpa,Java,Spring Boot,Jpa,不能使用@Query执行存储过程 必须在实体上定义NamedStoredProcedureRequesty 2021-05-06 00:26:04.506 ERROR 14840 --- [ scheduling-1] o.h.engine.jdbc.spi.SqlExceptionHelper : Incorrect syntax near '('. 2021-05-06 00:26:04.513 ERROR 14840 --- [ scheduling-1] o.s.

不能使用@Query执行存储过程

必须在实体上定义NamedStoredProcedureRequesty

2021-05-06 00:26:04.506 ERROR 14840 --- [   scheduling-1]    o.h.engine.jdbc.spi.SqlExceptionHelper   : Incorrect syntax near '('.
2021-05-06 00:26:04.513 ERROR 14840 --- [   scheduling-1]    o.s.s.s.TaskUtils$LoggingErrorHandler    : Unexpected error occurred in scheduled task    
org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is
org.hibernate.exception.SQLGrammarException: could not extract ResultSet
然后您可以使用@Procedure来执行它

@Entity
@NamedStoredProcedureQuery(name = "User.plus1", procedureName = "plus1inout", parameters = {
  @StoredProcedureParameter(mode = ParameterMode.IN, name = "arg", type = Integer.class),
  @StoredProcedureParameter(mode = ParameterMode.OUT, name = "res", type = Integer.class) })
public class User {}
请阅读文档:

@Entity
@NamedStoredProcedureQuery(name = "User.plus1", procedureName = "plus1inout", parameters = {
  @StoredProcedureParameter(mode = ParameterMode.IN, name = "arg", type = Integer.class),
  @StoredProcedureParameter(mode = ParameterMode.OUT, name = "res", type = Integer.class) })
public class User {}
@Procedure
Integer plus1inout(@Param("arg") Integer arg);