Lukasz Antoniak Check this code sample.
@Audited @Entity(name = "ClassA") @Table(name = "ClassA") @Inheritance(strategy = InheritanceType.JOINED) @IdClass(ClassId.class) public class ClassA{ @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "Id") private Long; @Id @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED) @ManyToOne(fetch = FetchType.LAZY, optional = false) @JoinColumn(name = "ClassTypeName", referencedColumnName = "Name", insertable = true, updatable = true, nullable = false) @ForeignKey(name = "FK_ClassA_ClassType") private ClassType type; ... }
public static class ClassId { private Long id; private ClassType type; ClassId (){} }
@Audited @Entity(name = "ClassB") @Table(name = "ClassB") @PrimaryKeyJoinColumns({ @PrimaryKeyJoinColumn(name = "ClassBId", referencedColumnName = "Id"), @PrimaryKeyJoinColumn(name = "ClassTypeName", referencedColumnName = "ClassTypeName") }) @Check(constraints = "ClassTypeName= 'VALUE'") public class ClassB extends ClassA { @ManyToOne(fetch = FetchType.LAZY, optional = true) @JoinColumn(name = "ClassCId", referencedColumnName = "Id", insertable = true, nullable = true, updatable = true) @ForeignKey(name = "FK_ClassB_ClassC") private ClassC classC; ... }
And BTW your code works, I have tried it with this sample. But I can't have the Auto generated Id used as part of the composite key, since EmbeddedId can't use that. Although the code sample is not using the embeddedid, it gives the same error.
Lukasz Antoniak Check this code sample.
And BTW your code works, I have tried it with this sample. But I can't have the Auto generated Id used as part of the composite key, since EmbeddedId can't use that. Although the code sample is not using the embeddedid, it gives the same error.