client resttemplate passes object with data collection, however api Rest only receives the main object

Asked

Viewed 20 times

-1

I have a class with a list of another object, but the api only takes the main object

@Entity
public class Vendacabecalho implements Serializable {


    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Column(name = "CCF")
    private Integer ccf; 
    @Column(name = "COFINS")
    private Double cofins;
    @Column(name = "COO")
    private Integer coo;
    @Column(name = "CPFouCNPJCliente")
    private String cPFouCNPJCliente;
    @Column(name = "ICMS")
    private Double icms;
    @Column(name = "ICMSOutras")
    private Double iCMSOutras;
    @Column(name = "ISSQN")
    private Double issqn;
    @Column(name = "PIS")
    private Double pis;
    @Column(name = "acrescimo")
    private Double acrescimo;
    @Column(name = "acrescimoItens")
    private Double acrescimoItens;
    @Column(name = "baseICMS")
    private Double baseICMS;
    @Column(name = "cancelada")
    private String cancelada;
    @Column(name = "dataHoraVenda")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dataHoraVenda;
    @Column(name = "desconto")
    private Double desconto;
    @Column(name = "descontoItens")
    private Double descontoItens;
    @Column(name = "idCFOP")
    private Integer idCFOP;
    @Column(name = "idCliente")
    private Integer idCliente;
    @Column(name = "idDAV")
    private Integer idDAV;
    @Column(name = "idMovimento")
    private Integer idMovimento;
    @Column(name = "idPreVenda")
    private Integer idPreVenda;
    @Column(name = "idVendaPdv")
    private Integer idVendaPdv;
    @Column(name = "idVendedor")
    private Integer idVendedor;
    @Column(name = "nomeCliente")
    private String nomeCliente;
    @Column(name = "percentualAproxTributos")
    private Double percentualAproxTributos;
    @Column(name = "statusVenda")
    private String statusVenda;
    @Column(name = "taxaAcrescimo")
    private Double taxaAcrescimo;
    @Column(name = "taxaDesconto")
    private Double taxaDesconto;
    @Column(name = "totalDocumento")
    private Double totalDocumento;
    @Column(name = "totalProdutos")
    private Double totalProdutos;
    @Column(name = "troco")
    private Double troco;
    @Column(name = "valorAproxTributos")
    private Double valorAproxTributos;
    @Column(name = "valorCancelado")
    private Double valorCancelado;
    @Column(name = "valorFinal")
    private Double valorFinal;
    @Column(name = "valorRecebido")
    private Double valorRecebido;
    @Column(name = "valorVenda")
    private Double valorVenda;
    @Basic(optional = false)
    @Column(name = "origemVenda")
    private int origemVenda;
    @Column(name = "comissaoPrazo")
    private Double comissaoPrazo;
    @Column(name = "comissaoVista")
    private Double comissaoVista;
    @Column(name = "taxaOperadoraPagamento")
    private Double taxaOperadoraPagamento;
    @Column(name = "sincronizado_nuvem")
    private Boolean sincronizadoNuvem;
    @Column(name="data_hora_sincronizado")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dataHoraSincronizado;
    @Column(name ="id_loja")
    private String idLoja;
  /*@JoinColumn(name = "idNfe", referencedColumnName = "id")
    @ManyToOne
    private Nfecabecalhoemissao idNfe; */
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idVendaCabecalho",fetch = FetchType.EAGER)
    @JsonBackReference
    private Collection<Vendadetalhe> vendadetalheCollection;
    @JsonBackReference(value = "totaltipopagamentoCollection")
    @Fetch(value = FetchMode.SUBSELECT)
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idVendaCabecalho", fetch = FetchType.EAGER)
    private Collection<Totaltipopagamento> totaltipopagamentoCollection;

endpoint api

 @PostMapping("/cupom")
    @ResponseBody
    public void atualizaVenda(@RequestBody Vendacabecalho vendaCabecalho) throws SQLException {
        System.out.println();
        }

1 answer

0

solved, I managed to find the solution, there was a class that was looped in json, I searched in the book Beginning Spring Boot 2, and put some indicated notations, such as

Generator = Objectidgenerators.PropertyGenerator.class, Property = "id") public class Vendacabecalho Serializable Mplements {

Browser other questions tagged

You are not signed in. Login or sign up in order to post.