• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Hibernate - mapping FK from one column to two different tables

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 .

Ex : if fees_id=1 and fees_type=1 , then it means it's a foreign key to doc_fees table
if fees_id=1 and fees_type=2 , then it means it's a foreign key to test_fees table

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.

my objective is that , i would like to join itemised_bill and doc_fees and test_fees in so that with one foreign key fees_id , so that ill get the bill itinerary or a particular person .
Thank you
 
Hey! Wanna see my flashlight? It looks like this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic