I am calling a stored procedure using IN parameter - it's working fine.
public interface ABCRepository extends JpaRepository<ABC, Integer> {
@Query(nativeQuery=true, value="exec p_NextSequence :clazName , 1")
Integer callSequenceForClaz(@Param ("clazName")String clazName);
}
Need help how to do it for OUT parameters.
Refer below link for how to call a stored procedure.
https://dzone.com/articles/calling-stored-procedures-from-spring-data-jpa
Simply define method annnotating it with Stored Procedure name, Map input param of stored Procedure with method parameters, Map output param of SP as the return type of the method, Example.
@Repository
public interface EmployeeJPA extends JpaRepository<Employee, Long> {
@Procedure(procedureName = "enroll_employee_program")
public String enrollEmpProgram(Long employeeId, Long programId, LocalDate createdDate, String createdBy);
}
You can use @Procedure used on a repository
@Procedure(procedureName="SP_MP_LOG_CONSULTA",outputParameterName="response")
int called(@Param("name") name);
I had to use the outputParameterName --> cause it was giving me an out undefined column error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With