0

I have created a below java service to find an employee by it's Id for that I have created a employeeRepository extends JPArepository to findById but here I want to call a stored procedure with in java service from SQL Server and pass the Employee id as parameter and to get the result to take it up further.

@GetMapping("/employees/{id}")
 public ResponseEntity<Employee> getEmployeeById(@PathVariable(value = "id") Long employeeId)throws ResourceNotFoundException {
     Employee employee = employeeRepository.findById(employeeId)
     .orElseThrow(() -> new ResourceNotFoundException("Employee not found for this id :: " + employeeId));
     return ResponseEntity.ok().body(employee);
 }

Could anyone pleases guide how to call a stored procedure with in java service spring boot application

Dale K
  • 25,246
  • 15
  • 42
  • 71
Mohan vel
  • 505
  • 9
  • 29
  • 1
    https://stackoverflow.com/questions/42531970/correctly-call-a-stored-procedure-using-spring-data-jpa – Kapil Jan 09 '20 at 07:51
  • 1
    A quick google search gives me this: https://www.logicbig.com/tutorials/spring-framework/spring-data/stored-procedure.html https://www.google.com/search?q=spring%20jpa%20repository%20stored%20procedure%20example – polve Jan 09 '20 at 07:53
  • 1
    Like this https://stackoverflow.com/questions/9361538/spring-jdbc-template-for-calling-stored-procedures JDBC/SQL-wise or like this https://www.baeldung.com/jpa-stored-procedures JPA-wise. One might also consider placing the call behing custom repository method as of https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#repositories.custom-implementations – Michal Jan 09 '20 at 08:07

0 Answers0