I will try. Please let me know if it is still unclear.
Bank offers Deals.
So on Java level, Bank has a List of Deal object.
Now Customer comes. He takes the deal and that creates a Contract.
A Customer can make many contracts.
So Customer->List<Contract>
Also, a Contract is something from a Deal.
So Contract has a foreign key from Deal.
Code:
class Bank{
mappedBy=Bank
private List<Deal> deals;
}
class Customer{
mappedBy=Customer
private List<Contract> contracts;
}
class Contract{
private Customer customer;
private Deal deal;
}
class Deal {
private Bank bank;
}
Hope it is clear till now.
Now on front end, I wanted to see how many contracts the Bank did (irrespective of customers).
So I just create a List of Contract in Bank, which is mappedBy=Deal
Code:
mappedBy=Deal
private List<Contract> contracts;
What did not work was
Code:
mappedBy=Deal.bank
private List<Contract> contracts;
May be I am just making it over complicated..... any suggestions are welcome.