Angel Villalain commented on Improvement HHH-4751

Lukasz Antoniak Check this code sample.

@Audited
@Entity(name = "Income")
@Table(name = "Income")
@Inheritance(strategy = InheritanceType.JOINED)
@IdClass(IncomeId.class)
public class Income{
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "Id")
    private Long;
    @Id
    @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JoinColumn(name = "IncomeTypeName", referencedColumnName = "Name",
                insertable = true, updatable = true, nullable = false)
    @ForeignKey(name = "FK_Income_IncomeType")
    private IncomeType type;
...
}
public static class IncomeId {
    private Long id;
    private IncomeType type;

    IncomeId(){}
}
@Audited
@Entity(name = "Salary")
@Table(name = "Salary")
@PrimaryKeyJoinColumns({
    @PrimaryKeyJoinColumn(name = "SalaryId",
                          referencedColumnName = "Id"),
    @PrimaryKeyJoinColumn(name = "IncomeTypeName",
                          referencedColumnName = "IncomeTypeName")
})
@Check(constraints = "IncomeTypeName = 'SALARY'")
public class Salary extends Income {
    @ManyToOne(fetch = FetchType.LAZY, optional = true)
    @JoinColumn(name = "EmploymentId", referencedColumnName = "Id",
                insertable = true, nullable = true, updatable = true)
    @ForeignKey(name = "FK_Salary_Employment")
    private Employment employment;
...
}
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira