Relaciones en JPA.
Maestros Detalles
Opción 1.
En este caso solo se relaciona la tabla 12 con la tabla 8, una relación maestro detalle muy sencilla. Es unidireccional.
@Entity
@Table(name = "t12factura")
public class Invoice extends EntityFather implements Serializable {
@OneToMany
@JoinColumn(name = "a08factura", referencedColumnName = "a12id")
private List<InvoicePayments> listPayment = new ArrayList<>();
@Entity
@Table(name = "t08tipopago_factura")
public class InvoicePayments extends EntityFather implements Serializable {
@Id
@Column(name="a08factura")
private int idFactura;
Opción 2.
Una segunda opción que cumple la misma función de la opción 1 es la siguiente.
@Entity
@Table(name = "t12factura")
public class Invoice extends EntityFather implements Serializable {
@OneToMany(mappedBy="invoice")
private List<InvoicePayments> listPayment = new ArrayList<>();
@Entity
@Table(name = "t08tipopago_factura")
public class InvoicePayments extends EntityFather implements Serializable {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "a08factura")
private Invoice invoice = new Invoice();


