I have a stored procedure.
CREATE OR REPLACE PROCEDURE rvprficreationadm.copy_questions(IN target_componentid uuid, INOUT source_questionids uuid[], IN createdby uuid, IN is_copied_from_qb boolean, IN createdThrCd varchar)
This procedure is working fine if i am calling it from the database. But when i call the same procedure using java through Hibernate it is failing with below error message
ERROR: function rvprficreationadm.copy_questions(uuid, bytea, uuid, boolean, character varying) does not exist
Here is my java code to call the procedure.
package com.gartner.rvp.rfi.creation.repository.impl;
import com.gartner.rvp.rfi.creation.repository.CopyQuestionProcedure;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import javax.persistence.EntityManager;
import javax.persistence.ParameterMode;
import javax.persistence.StoredProcedureQuery;
import javax.transaction.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
@Repository
public class CopyQuestionProcedureImpl implements CopyQuestionProcedure {
@Autowired
private EntityManager entityManager;
@Override
@Transactional
public List<UUID> copyQuestions(UUID componentId, List<UUID> targetQuestionIds, UUID userId) {
StoredProcedureQuery query = entityManager.createStoredProcedureQuery("rvprficreationadm.copy_questions");
// Register the parameters
query.registerStoredProcedureParameter(1, UUID.class, ParameterMode.IN);
query.registerStoredProcedureParameter(2, UUID[].class, ParameterMode.INOUT);
query.registerStoredProcedureParameter(3, UUID.class, ParameterMode.IN);
query.registerStoredProcedureParameter(4, Boolean.class, ParameterMode.IN);
query.registerStoredProcedureParameter(5, String.class, ParameterMode.IN);
// Set the parameter values
query.setParameter(1, componentId);
query.setParameter(2, targetQuestionIds.toArray(UUID[]::new));
query.setParameter(3, userId);
query.setParameter(4, false);
query.setParameter(5, "COPY_QUESTION");
// Execute the query
query.execute();
// Get the result (updated INOUT parameter)
UUID[] resultArray = (UUID[]) query.getOutputParameterValue(2);
return List.of(resultArray);
}
}
This is failing on 2nd parameter because it is considering it as bytea type.
Is there any solution for this? Please let me know.
I tried calling it through List and UUID[] both are failing.