I am trying to fetch multiple results from a store procedure to spring side but somehow I am getting this error:
org.hibernate.exception.SQLGrammarException: Error extracting results from CallableStatement
at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:106)
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111)
at org.hibernate.result.internal.OutputsImpl.convert(OutputsImpl.java:79)
at org.hibernate.result.internal.OutputsImpl.extractResults(OutputsImpl.java:139)
at org.hibernate.result.internal.OutputsImpl.extractCurrentResults(OutputsImpl.java:127)
My store procedure is like, Example:
DELIMITER ;;
CREATE PROCEDURE `USER_LIST`()
BEGIN
SET @sqlSelect = 'SELECT * from profile WHERE is_email_verified = 0';
PREPARE stmt FROM @sqlSelect;
EXECUTE stmt;
SET @sqlSelect = 'SELECT * from user WHERE is_phone_verified = 0';
PREPARE stmt FROM @sqlSelect;
EXECUTE stmt;
END;;
DELIMITER ;
In Spring side:
StoredProcedureQuery storedProcedure = entityManager.createStoredProcedureQuery("USER_LIST");
// Execute stored procedure
storedProcedure.execute();
List<Object[]> storedProcedureResults = storedProcedure.getResultList();
if(storedProcedure.hasMoreResults())
{
System.out.println("Print");
}
I am getting that error in if condition where I write storedProcedure.hasMoreResults().
Is there any possible way to get both the result list at spring side?
Please help me out to solve this out. Thanks in advance.