Hibernate version: 3.2.2
Hopefully a simple example to show what I mean:
A HousePurchaseTransaction has a buyer and a seller (both instances of TransactionOwner), if we wanted to capture that relationship it would be normal to link buyer and seller PK in HousePurchaseTransaction, but this is not done, instead the TransactionOwner class has a relation to the HousePurchaseTransaction, and another column holds a ownerType flag to indicate whether they were the purchaser or the seller:
HousePurchaseTransaction
number hptPk (oracle seq generated)
xxx other data
TransactionOwner
number toPk(oracle seq generated)
number hptPk (foreign key to above)
string ownerType (either buyer or seller)
All works fine when saving the data but come to reload time (call read on the HousePurchaseTransaction) how can it differentiate between the two owners, on the 'one to one's both say:
@OneToOne (mappedBy = "houseTransactionOwner)
getBuyer();
@OneToOne (mappedBy = "houseTransactionOwner)
getSeller();
I need to put a second join column in here, something like
@OneToOne (mappedBy = "houseTransactionOwner, where = "ownerType = 'Seller'")
getSeller();
Anyone have any idea how this might be possible?
Thanks, (points will be awarded)
Chris.
|