Good afternoon, I am relatively new to spring boot, and I am working with a rest service that receives a telephone number as a parameter, and in turn in the database a stored procedure must be executed that should validate it, the same stored procedure will return A response that brings a code and response, both parameters must be presented in a json response to the request, attached example:

Input:

04258978417

Output:

{ "ValidateClient": { 
    "Body": {
         "Code": "NA22001", 
          "Message": "Fecha Maxima de asignacion del cliente.", 
             }
      }
}

ejecucion SP

The Storage Procedure is as follows:

CREATE PROCEDURE ValidacionClienteBonificado (p_movil varchar(11))
BEGIN

if exists (select '' from ClienteBonificados a where a.movil=p_movil) then
    if exists (select '' from ClienteBonificados a where a.contador=0 and a.movil=p_movil) then
        if (select a.fecha_fin<current_timestamp() from ClienteBonificados a where a.fecha_fin<current_timestamp() and a.movil=p_movil ) then
            select 'Fecha Maxima de asignacion del cliente' as result, 'NA22001' as code;
        else
            select 'Cliente aplica para bono' as result, '00000' as code;
        end if;
    else
        select 'Bono asignado a cliente' as result, 'NA22002' as code;
    end if;
else
    select 'Cliente no encontrado' as result, 'NA22003' as code;
end if;

At the moment I am creating the entity, but I have doubts how to place the output parameters, according to what I have investigated, since it does not return anything related to the parameters of the table:

table ClienteBonificados(
id int auto_increment primary key,
movil varchar(11) not null,
contador char(1) not null,
fecha_driver datetime,
fecha_alta datetime,
fecha_fin datetime,
codigo_transaccion varchar(5)
)

Then my code:

package com.app.validacion.entity;

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedStoredProcedureQueries;
import javax.persistence.NamedStoredProcedureQuery;
import javax.persistence.ParameterMode;
import javax.persistence.StoredProcedureParameter;
import javax.persistence.Table;

@Entity
@Table
@NamedStoredProcedureQueries({
    @NamedStoredProcedureQuery(
            name="ProcedueValidationCliente",
            procedureName="ValidacionClienteBonificado",
            parameters = {
                    @StoredProcedureParameter(mode=ParameterMode.IN, name="p_movil",type=String.class), 
                    @StoredProcedureParameter(mode=ParameterMode.OUT, name="result",type=String.class),
                    @StoredProcedureParameter(mode=ParameterMode.OUT, name="code",type=String.class),
            })

})
public class DriverBonificados {

    @Id
    private int id;
    private String movil;
    private String contador;
    private Date fecha_driver;
    private Date fecha_alta;
    private Date fecha_fin;
    private Date codigo_transaccion;

}

In this case the response of the database would go within the configuration of @NamedStoredProcedueQueries?

I have doubts on how to build my DAO / Repository, since I have done it, but with an answer related to the object or entity of the database

Comment From: bclozel

Thanks for getting in touch, but it feels like this is a question that would be better suited to StackOverflow. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements. Feel free to update this issue with a link to the re-posted question (so that other people can find it) or add some more details if you feel this is a genuine bug.