Though I posted this issue before let me rephrase again with some example. Lets say Customer and Order has one to many relationship. Assume Customer C1 has 2 Orders O1 and O2. In Customer entity I defined collection of Orders and annotated it as OneToMany. In Orders I defined Customer and annotated it as ManyToOne and JoinColumn. So code looks something like this
In Customer
private List<Orders> orderList = new ArrayList<Orders>(); @OneToMany(mappedBy="customer", fetch=FetchType.EAGER, cascade=CascadeType.ALL) public List<Orders> getOrderList() { return orderList; } @Version @Column(name="Version", insertable=false, updatable=false) public int getVersion() { return version; }
private Customers customer; @ManyToOne() @JoinColumn(name="CustomerID") public Customers getCustomer() { return customer; } @Version @Column(name="Version", insertable=false, updatable=false) public int getVersion() { return version; }