Hibernate - mapping FK from one column to two different tables
posted 2 years ago
Hi all ,
I'm pretty new to hibernate and i'm working on a module which consists of 3 tables namely Doc_fees_master , Test_fees_master and there is an itemised_bill table , and the relation is as follows
itemised_bill - ID , Fees_id , fees_type
doc_fees_master - ID , fees , Doctorname , specialization
test_fees_master - ID , testname , fees
Now the fees_id field in itemised_bill is the ID field of doc_fees_master , so it could be like Fees_id=1 can exist in both doc_fees_master and test_fees_master , or in any one of them .
i'm using hibernate and i tried to map many-to-one relation on fees_id(itemised_bill) to both doc and test tables , which doesn't work , because same column cannot be referenced to 2 different tables , please let me know the right mapping to be done in hibernate using XML file and not annotations.