Reputation: 1302
I have the following Scheme
@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 class B and C extends A and get their id From A using table per concrete class strategy but the problem is that class B has one to many relationship with class C so what i want is to change the id of class C to be a composite key consist of the inherited id field1 and the id of the object b. That will allow two different object of b to have the two different object of c with the same field1 value. Is what i am thinking possible (override inheritance) i am using eclipse link as persistence provider.
Upvotes: 4
Views: 304
Reputation: 61538
Unfortunately, having different Id types in an entity hierarchy is not supported by the JPA inheritance strategies as it introduces ambiguities.
See this question for details.
to work around this limitation you could:
C
from the hierarchy so that it does not derive from A
C
as an attribute in a different entity Upvotes: 2