Stored procedure name changed during execution using Spring Data Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of Stored procedure name changed during execution using Spring Data without wasting too much if your time.

The question is published on by Tutorial Guruji team.

I need to call an Oracle stored procedure using Spring annotation @Procedure in my Repository as follows:

    @Procedure(name = "SECURITE.P_MAJ_DROITFAM")
    public void updateDroitFamille (@Param("v_id_fam") Long idFamille,@Param("v_action_type") Integer cas,@Param("v_user") String userName);

Error log :

Hibernate: {call updateDroitFamille (?,?,?)} 15: 46: 39,946 – ERROR – SqlExceptionHelper.logExceptions: 146 – ORA-06550: Line 1, column 7: PLS-00201: The identifier ‘UPDATEDROITFAMILLE’ must be declared

but procedure name is P_MAJ_DROITFAM and not updateDroitFamille
The problem is that the procedure name has been changed during execution!!? any ideas?

Answer

What you need to do is put additional configuration on one of your entities do declare the definition of your procedure first in the application:

@NamedStoredProcedureQuery(name = "P_MAJ_DROITFAM", procedureName = "SECURITE.P_MAJ_DROITFAM", parameters = {
        @StoredProcedureParameter(mode = ParameterMode.IN, name = "v_id_fam", type = Long.class),
        @StoredProcedureParameter(mode = ParameterMode.IN, name = ""v_action_type", type = Integer.class) },
        @StoredProcedureParameter(mode = ParameterMode.IN, name = ""v_user", type = Integer.class) })
public class MyEntity{

Then in the repository you would call like:

@Procedure(name = "P_MAJ_DROITFAM")
    public void updateDroitFamille (@Param("v_id_fam") Long idFamille,@Param("v_action_type") Integer cas,@Param("v_user") String userName);

You can keep the name of the method.

We are here to answer your question about Stored procedure name changed during execution using Spring Data - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji