• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

How to do mapping in JPA when a table has a column that references 2 other table columns

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am having a table A with following structure:

Table A
Column a1(PK)
Column a2
.....

Table B
Column b1(PK)
Column b2
........


Table C
Column c1(PK)
Column c2
Column a1b1
......


In Column a1b1 of Table C we are storing the values from PK Column a1 from table A or PK Column b1 from Table B. i.e, some rows in Table C relates to Table A and some relates to Table B depending on this Column "a1b1" column value.
Please help me in doing the mapping for this case in JPA Annotations.


I have used below mapping that was NOT working.


 
Poop goes in a willow feeder. Wipe with this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic