Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

monika se
Posts: 22
  • Mark post as helpful
  • send pies
  • 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.

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!