我使用此页面指导自己如何做 https://dzone.com/articles/calling-stored-procedures-from-spring-data-jpa
我需要使用Hibernate和Repositories在Oracle DB中调用存储过程。我的过程收到1个IN参数和2个OUT参数,我在我的应用程序中并没有真正使用OUT参数。
我的程序收到了这个
create or replace procedure PRD_DIC_SISTEMA(P_NRO_EVALUACION number
,P_DICTAMEN out varchar2
,P_RESPUESTA out varchar2) is
我的服务
public ResultsDTO getSystemEvaluation(Long evaluationCode) throws BusinessException {
ResultsDTO response = new ResultsDTO();
dictaminationOperationRepository.systemDictaminationResults(evaluationCode);
return response;
}
存储库
public interface DictaminationOperationRepository extends CrudRepository<DictaminationOperation,DictaminationOperationPK>{
@Transactional
@Procedure(procedureName="prd_dic_sistema")
void systemDictaminationResults(@Param("p_nro_evaluacion") Long evaluationCode);
}
我的豆类
@Entity
@Table(name="WP_EVA_DIC_OPERACIONES")
@JsonInclude(Include.NON_NULL)
@NamedStoredProcedureQueries({
@NamedStoredProcedureQuery(
name = "prd_dic_sistema",
procedureName = "prd_dic_sistema",
parameters = {
@StoredProcedureParameter(mode = ParameterMode.IN, name = "p_nro_evaluacion", type = Long.class),
@StoredProcedureParameter(mode = ParameterMode.OUT, name = "p_dictamen", type = String.class),
@StoredProcedureParameter(mode = ParameterMode.OUT, name = "p_respuesta", type = String.class)
}
)
}
)
public class DictaminationOperation implements Serializable {
attributes, constructor, getters and setters...
}
我的错误
调用CallableStatement.getMoreResults时出错; SQL [prd_dic_sistema]; 调用“ PRD_DIC_SISTEMA”时参数类型错误数量