[英]How Execute Stored Procedure using JPA annotation @NamedStoredProcedureQuery
How convert this procedure execution using @NamedStoredProcedureQuery?如何使用@NamedStoredProcedureQuery 转换此过程执行?
I have this SQL, It's OK!我有这个SQL,没关系!
SQL (it's Works OK): SQL(工作正常):
USE [INTEGRADOR]
GO
DECLARE @return_value int
EXEC @return_value = [dbo].[SP_VW_PEDIDOSDECOMPRA_SGM]
@CODIGO = 71648
SELECT 'Return Value' = @return_value
GO
In Java i Try this, but not working.在 Java 我试试这个,但不工作。 idUsuarioAutenticado is @CODIGO = 71648
idUsuarioAutenticado 是 @CODIGO = 71648
JAVA (Error when compile): JAVA(编译时出错):
@NamedStoredProcedureQuery(
name = "listarComprasMicrosigaProc",
procedureName = "INTEGRADOR.DBO.SP_VW_PEDIDOSDECOMPRA_SGM",
resultClasses = AcompanhamentoCompraPortalEntity.class,
parameters = {
@StoredProcedureParameter(mode = ParameterMode.IN, type = Long.class)
}
)
public List<AcompanhamentoCompraPortalEntity> listarComprasMicrosigaProc(@Param("idUsuarioAutenticado") Long idUsuarioAutenticado);
Not compile.不编译。
I received this errors:我收到了这个错误:
The annotation @NamedStoredProcedureQuery is disallowed for this location
此位置不允许使用注释 @NamedStoredProcedureQuery
My imports (Java):我的进口(Java):
import java.util.List;
import java.util.Set;
import javax.persistence.NamedStoredProcedureQuery;
import javax.persistence.StoredProcedureParameter;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
Instead of at field /attribute level, you have to add the @NamedStoredProcedureQuery
annotation and its details at class level:而不是在字段/属性级别,您必须在class级别添加
@NamedStoredProcedureQuery
注释及其详细信息:
@Entity
@NamedStoredProcedureQuery(
// further specifications ...
)
public class MyEntity {
// fields, getter/setter methods, etc.
}
With that corrected, the error (message)更正后,错误(消息)
The annotation @NamedStoredProcedureQuery is disallowed for this location
此位置不允许使用注释 @NamedStoredProcedureQuery
should disappear.应该消失。
Hope it helps.希望能帮助到你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.