gcook1@shaw.ca wrote:
alfbolide wrote:
The most flexible solution probably is mapping all these 3 classes and the two many-to-one association between them.
I don't think I agree. Consider the following classes:
Code:
public class BankingCustomer {
IList<Account> _Accounts;
}
public class Account {
IList<BankingCustomer> _accountOwners;
}
This is a many-to-many as a Customer may have many accounts, and an account can be a joint-account between 2 or more Customers.
The table structure though needs the intersecting table for the associations, your domain model does not in this case.
This is the goal of an ORM tool, is to allow developers of the Domain model to design their domain objects independant of the database implementation.
What your suggesting is to map your domain objects to reflect the table structure. That is a more TableModule design pattern instead of the domain model pattern.
I don't think I was suggesting a TableModule design. Actually it is also recommended by Hibernate in Action (check out the banner).
In my experience, adding an intermediate class between Account and Customer will give you the following strength:
first, you will have a class that can help manage this complex association.
secondly, in this class, you can store more information such as the time when a customer is added as an extra owner to the joint-account or the priority of the owners over the account.
This design might not be suitable for you domain but these two capabilities just give you more flexibility as I was suggesting.