How to cast in Java?

This model is working, look at the figure!

insert the description of the image here

You may notice that you are concatenating two string variables as you can see in the figure below;

insert the description of the image here

My problem now is to be able to concatenate an Integer variable with a string variable, because eclipse does not allow, as you can see below;

insert the description of the image here

I would have to do a cast , but I'm having difficulty to do for lack of experience, I need help in this regard!

This is the Code;

/*lista de NaoConformidade*/
@Autorizacao(values = { AutorizacaoSistema.M_ADM })
public List<TipoInconsistenciaEntity> getListNaoConformidade() {
    AbstractCriteriaSearch<TipoInconsistenciaEntity> filtro =
            new AbstractCriteriaSearch<TipoInconsistenciaEntity>(new TipoInconsistenciaEntity());
    filtro.addOrder("codigo", ASC);
    List<TipoInconsistenciaEntity> lista = tipoInconsistenciaService.listarEntidades(filtro);
    List<TipoInconsistenciaEntity> listaRetorno = new ArrayList<TipoInconsistenciaEntity>();

    for (TipoInconsistenciaEntity pj : lista) {
        if(pj.getCodigo() > 5000) {
            TipoInconsistenciaEntity p = new TipoInconsistenciaEntity();
            p.setDescricao(pj.getDescricao());
            p.setCodigo(pj.getCodigo() + " - ["+ pj.getDescricao() + "]");

            listaRetorno.add(p);
        }
    }
    return listaRetorno;
}
 0
Author: wladyband, 2019-05-07

1 answers

I created a variable in the entity receiving Getts and Setts

insert the description of the image here

Then I made this small change to the method;

insert the description of the image here

And it worked!

insert the description of the image here

 0
Author: wladyband, 2019-05-07 11:19:01