Ronak
Ronak

Reputation: 43

Spring Data JPA - Stored procedure return multiple result with non-entity

I'm using the spring data JPA repository to call the stored procedure. As if throughout the application we have a tight dependency on the stored procedure I have to go with non-entity store procedure call. Below is the way I choose to call it:

@Query(value = "EXEC getAllOperation ?,?,?", nativeQuery = true)
Object[][] getAllOperation (@Param("user_details") int userId);

It works well in all where stored procedure returns single resultset.

But it does not work with stored procedure returning multiple resultsets. It returns the first resultset only and not giving any error.

We have spring-boot-starter-data-jpa version 1.5.8 and hibernate-jpa version 2.1 in our project.

I have gone through several threads for this solution. But could not find any solution if I want to achieve this using the current approach only.

Please help me with this.

Upvotes: 2

Views: 5558

Answers (1)

Jens Schauder
Jens Schauder

Reputation: 82008

In general Spring Data JPA supports multiple out parameters of stored procedures by returning them in a Map (see https://jira.spring.io/browse/DATAJPA-707).

I doubt though that this works with some parameters being ResultSets.

As an alternative you can always create a custom method and implement it directly on the EntityManager or a JdbcTemplate.

Upvotes: 0

Related Questions