I'm sorry for the dumb title, but I'm just starting to tinker with hibernate (loving it btw) and i'm finding that the way I'd normally design my objects presents an issue.
to abridge my application: I have an Account class with a set of Transfers Set<Transfer> my Transfer class has two instances of Account Account source; Account destination;
I've learned by trying that I can't have two many-to-one relationships in the Transfer class, which makes sense I just thought it was worth a try...I'd prefer not to have a set of Accounts in the Transfer class. From doing lots of searching I think a solution would be to add two classes, TransferSource and TransferDestination. so now
Account: TransferSource sourceTransfers; TransferDestination destTransfers; TransferSource: Set<Transfer> transfersFrom; TransferDestination: Set<Transfer> transfersTo; Transfer: TransferSource source; TransferDestination dest;
But now I have a one-to-one between Account and each of TransferSource and TransferDestination with a one-to-many between each of those to Transfer. This seems convoluted to me even though I'm pretty sure it will work. My guess is that this is a pretty common pattern, problem and I have just failed to find the right info. could any one please make a suggestion or comment?
it is much appreciated.
|