0
class A{
@id
int a;
}

enter code here

class B {
@id
int b;
}

A

a ====> primary key

B

b ====> primary key

C

a and b needs to be primary key for the table. Also a and b are foreign key

How to add a and b into the third table(C) as a primary key which also needs to be foreign key too?

Piyush Mittal
  • 1,790
  • 1
  • 18
  • 39
Sathya
  • 1
  • 2

1 Answers1

0

You can use @EmbeddedId with @MapsId on to-one associations.

Examples can be found here, here and in the official documentation.

Community
  • 1
  • 1
Dragan Bozanovic
  • 22,362
  • 4
  • 40
  • 106