[英]passing multiple @params to stored procedure in JPA
@Query(value = "DECLARE @StartDateTime DATETIME = DATEADD(hour,-1,GETUTCDATE()) EXEC [Fetch].[mevisio_downtimedata] " +
"@StartDateTime = :startDateTime," +
"@workCenterList = :workCenterList",nativeQuery = true)
List<DownTimeData> retriveOneHrDowntime(@Param("startDateTime") LocalDateTime startDateTime, @Param("workCenterList") List<String> workCenterList);
Getting Error:得到错误:
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
You cannot execute stored procedures with a @Query
您不能使用
@Query
执行存储过程
You have to define a NamedStoredProcedureQuery
on an entity您必须在实体上定义
NamedStoredProcedureQuery
@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 {}
And then you can use @Procedure
to execute it然后你可以使用
@Procedure
来执行它
@Procedure
Integer plus1inout(@Param("arg") Integer arg);
Please read the documentation: https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#jpa.stored-procedures请阅读文档: https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#jpa.stored-procedures
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.