I have the following two classes. I want the order to contain a list with orderlines. My question is how I make a mapping such that I automatically can retrive the orderlines when I get the order object. And visa verca, if I build up a object with order and a list with orderlines, how do I make the mapping such that when I save the order object, I also save the orderline list in that object.
@Entity @Table (name="supplierorder") public class SupplierOrder { @Id @Column(name = "id") private int id; @Column(name = "date") private Date orderdate;
private List<SupplierOrderLine> orderlines;
--getters and setters }
@Entity @Table (name="supplierorderline") public class SupplierOrderLine implements Serializable{
@Id @Column(name = "id") private int id; @ManyToOne @JoinColumn(name="fruit_id") private Fruit fruit; @ManyToOne @JoinColumn(name="supplier_id") private Supplier supplier; @Column(name = "number") private Integer number; @Column(name = "kiloprice") private Double kiloprice;
...getters and setters }
|