Reputation: 311
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.
Upvotes: 6
Views: 30470
Reputation: 1
Encontre este ejemplo que me funciono, saludos @Procedure(procedureName = "con_nombreSP", outputParameterName = "out_parameter") public double nameMethod (@Param ("in_param") double param, @Param ("in_param2") double param2, @Param ("in_param3") int param3);
Upvotes: 0
Reputation: 1445
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.
Upvotes: 1
Reputation: 1233
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);
}
Upvotes: 1
Reputation: 6962
Refer below link for how to call a stored procedure.
https://dzone.com/articles/calling-stored-procedures-from-spring-data-jpa
Upvotes: 3