I have a MappedSuperClass which contains the @IdClass attribute because and the children are sharing the same primary key object.
@MappedSuperclass
@IdClass(PK.class)
public abstract class ParentClass implements Serializable {
....
}
And the child entity simply extends the parent
@Entity
@Table(name="MyTable")
public class ChildClass extends ParentClass
When I call the getIdClassAttributes() method from the EntityType of ChildClass. I get an IllegalArgumentException.
Caused by: java.lang.IllegalArgumentException: No @IdClass attributes exist on the IdentifiableType [EntityTypeImpl@28384121:ChildClass [ javaType: class ChildClass descriptor: RelationalDescriptor(ChildClass --> [DatabaseTable(MyTable)]), mappings: 22]]. There still may be one or more @Id or an @EmbeddedId on type.
My current workaround is to add the @IdClass(PK.class) annotation to ChildClass...
Is my setting incorrect or is it a bug? Thanks.