java - JPA Inheritence IdClass -
How to use IDclass in multiple heritage units overall key case?
@IdClass (IdClassEntity1 classifieds) class Entity1 {Private long e1pk1; Private long e1pk2; } @ ID Class (ID Classy Class 2.) Class Entity2 Entity1 {Private long e2pk1; Private long E2P2; } Class Entity3 Entity2 {Private long e3pk1; Private long E3 PK2; }
What should be IdClassEntity2:
Class IdClassEntity2 {Private long e1pk1; Private long e1pk2; Private long E2 PK1; Private long E2P2; }
or
Class IdClassEntity2 {Private IdClassEntity1 idClassEntity1; Private long E2 PK1; Private long E2P2; }
You can use @MappedSuperClass
or as
@EdClass
. For example, by using @MappedSuperClass
, you can:
@MappedSuperClass @IdClass (IdClassEntity1) .class) Public Class Entity1 {@Id Private Long e1pk; @ Id private long e1pk; ... @Entity Public Class Entity2 Entity1 {...]
using @Entity
extends, follow the same pattern
Comments
Post a Comment