JPA problems persisting a cascading list a subclass

0

I have the following invoice and detail invoice classes where invoice

@Entity
@Table(name = "factura")
public class Factura implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "idfactura")
    private Integer idfactura;
    @Column(name = "fechalectura")
    @Temporal(TemporalType.DATE)
    private Date fechalectura;
    @Basic(optional = false)
    @Column(name = "numerocomprobante")
    private int numerocomprobante;
    @Column(name = "suptotal")
    private Double suptotal;
    @Column(name = "iva")
    private Double iva;
    @Column(name = "total")
    private Double total;
    @Column(name = "estado")
    private Boolean estado;
    @JoinColumn(name = "idconsumo", referencedColumnName = "idconsumo")
    @ManyToOne
    private Consumo idconsumo;
    @JoinColumn(name = "idcontribuyente", referencedColumnName = "idcontribuyente")
    @ManyToOne
    private Contribuyente idcontribuyente;
    @OneToMany(mappedBy = "idfactura", targetEntity = Detallefactura.class, cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    private List<Detallefactura> listdetallefactura = new ArrayList<>();

Invoice detail:

@Entity
@Table(name = "detallefactura")
public class Detallefactura implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "iddetallefactura")
    private Integer iddetallefactura;
    @Size(max = 100)
    @Column(name = "descripcion")
    private String descripcion;
    @Column(name = "importe")
    private Double importe;
    @Column(name = "total")
    private Double total;
    @ManyToOne(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY)//muchos a uno 
    @JoinColumn(name = "idfactura", referencedColumnName = "idfactura")
    private Factura idfactura;
    @Column(name = "cantidad")
    private Integer cantidad;

Method to create:

        objFactura.setSuptotal(valor);
        objFactura.setIva(valor * 0.12);
        objFactura.setTotal(objFactura.getSuptotal() + objFactura.getIva());
        objFactura.setListdetallefactura(lstDetallefacturas);
        facturaEJB.create(objFactura);

The problem is that when the invoice detail list was sent, the table does not display the invoice id

    
asked by Giovanni Scrz 13.07.2018 в 18:15
source

0 answers