Error in saving the third table - conflict in Integer and Long

0

I need to save on three tables. I can save the first two [simulations] and [response_investors].

I need to save the data in the table [background_simulation] ...

When executing the project, you are displaying the error when saving in the simulation table:

Caused by: java.lang.Error: Unresolved compilation problem: 
The method setFundo(Integer) in the type FundoSimulacao is not applicable for the arguments (Fundo)

at br.gov.caixa.simfi.service.SimulacaoService.save(SimulacaoService.java:76)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

The save method with error on line: fu.setFund (fundoService.findByCoFundoAnbima (fu.getCoFundoAnbima ());

    public Simulacao save(Simulacao simulacao) {

    List<RespostaInvestidor> respostas = simulacao.getRespostaInvestidor();
    List<FundoSimulacao> fundos = simulacao.getFundoSimulacao();

    simulacao.setRespostaInvestidor(null);
    simulacao.setFundoSimulacao(null);

    if (simulacao.getId() == null) {
        simulacaoRepository.insert(simulacao);
    } else {
        simulacaoRepository.update(simulacao);
    }

    if (respostas != null) {
        for (RespostaInvestidor ri : respostas) {
            ri.setSimulacao(simulacao);
            respostaInvestidorService.save(ri);
        }
    }

    if (fundos != null) {
        for (FundoSimulacao fu : fundos) {
            fu.setSimulacao(simulacao);
            **fu.setFundo(fundoService.findByCoFundoAnbima(fu.getCoFundoAnbima()));**
            fundoSimulacaoService.save(fu);
        }
    }       

    //simulacao.setRespostaInvestidor(respostas);
    return simulacao;
}

The findByCoFundoAnbima method in FundoService.java:

    /**
 * Carrega o fundo conforme o id
 * 
 * @param id
 * @return Fundo
 */
public Fundo findByCoFundoAnbima(Integer id) {

    return fundoRepository.findById(id);

}

The Entity FundSimulation.java:

@Entity

@Table (schema = Constants.SIMFI_SCHEMA_NAME, name = Constants.FUNDO_SIMULACAO_TABLE_NAME) @NamedQueries ({@NamedQuery (name = Constants.FUNDO_SIMULACAO_NAMED_QUERY, query = Constants.FUNDO_SIMULACAO_QUERY)}) public class FundoSimulacao implements AbstractEntity {

private static final long serialVersionUID = 1L;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = Constants.CO_FUNDO_SIMULACAO)
private Integer id;

@Column(name = Constants.CO_FUNDO, nullable = false)
private Integer fundo;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = Constants.CO_SIMULACAO)
private Simulacao simulacao;

@Transient
private Integer coFundoAnbima;

@Override
public Integer getId() {
    return id;
}

@Override
public void setId(Integer id) {
    this.id = id;
}

public Integer getFundo() {
    return fundo;
}

public void setFundo(Integer fundo) {
    this.fundo = fundo;
}

public Simulacao getSimulacao() {
    return simulacao;
}

public void setSimulacao(Simulacao simulacao) {
    this.simulacao = simulacao;
}

public Integer getCoFundoAnbima() {
    return coFundoAnbima;
}

public void setCoFundoAnbima(Integer coFundoAnbima) {
    this.coFundoAnbima = coFundoAnbima;
}

the table fields:

co_fundo_simulacao serial NOT NULL
co_fundo bigint NOT NULL
co_simulacao bigint NOT NULL
    
asked by anonymous 13.11.2018 / 17:30

0 answers