spring-data-jpa
spring-data-jpa copied to clipboard
How to call Stored Procedure with input array and output array as arguments using @Procedure or @Query ?
I have a stored procedure that has 2 arguments, one is input Array of Objects and the second is output Array of Objects. How to call this stored procedure from spring data jpa ? There are many questions on stack overflow who requires same kind of solution, It would be helpful to all of us, Because of this issue we are going with the old entity manager, connection object, session, and Struct array fashion which is too much code in the currently grown scenario.
My Question: StackOverflow question link
Expecting something like the below:
@Procedure("GET_TOTAL_CARS_BY_MODEL") Object[] getTotalCarsByModel(Student[] inpArray);
or
@Query(value = "CALL FIND_CARS_AFTER_YEAR(:inpArr,:outArry);", nativeQuery = true) Object[] findCarsAfterYear(@Param("inpArr") Student[] inpArr)
The link to your StackOverflow question doesn't go to StackOverflow. Please, provide the corrected link.
I think I found the correct question and edited the issue description.
There are multiple ways to invoke a stored procedure, as shown in https://docs.spring.io/spring-data/jpa/docs/3.0.0-M6/reference/html/#jpa.stored-procedures
To narrow things down, it would be helpful to:
- Tell us what database engine we're talking about. All of them have variances in how they do stored procedures.
- Show us some amount of code regarding both your stored procedure as well as your Java code attempting to invoke it.
- Details about the entity type involved in this stored procedure.
- What version of Spring Boot you are using. You mentioned "the old entity manager", which doesn't really clarify what that means.
I realize that stored procedures are quite popular to use, and JPA offers "a way" to hook into them, but they can, in fact, be quite brittle, so troubleshooting this requires a lot of detail.
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.