JPA Inheritance

I have the following diagram

@Entity
public class A

{
@Id
String field1
String field2
}
public class B extends A
{
 String field3;
 @OneToMany(MappedBy="b")
 List<C> cList;
}

public class C extends A
{
String field4;
@ManyToOne
B b;
}

Both classes B and C extend A and get their identifier from the table using the table for a specific class strategy, but the problem is that class B has one to many relations with class C, so I want to change the identifier of class C to be a composite key. consisting of the inherited field id1 and object identifier b. This will allow two different objects b to have two different objects c with the same field1 value. I think it is possible (override inheritance). I use the eclipse link as a continuity provider.

+4
source share
1 answer

, JPA, .

. .

, :

  • '' C , A
  • C
+2

All Articles