I have employee, role and empRoleMap. I have mapped them together -
[code] public class Employee {
@Id private EmployeePK id;
@ManyToOne @JoinTable( schema = "PROJECT", name = "EMP_ROLE_MAP", joinColumns = {@JoinColumn(name = "EMP_ID"),@JoinColumn(name = "EMP_ID_KEY")}, inverseJoinColumns = {@JoinColumn(name = "ROLE_CD"),@JoinColumn(name = "ROLE_CD_KEY")} ) private Role role; ..... [/code]
The problem I have is that the empRoleMap has multiple records with only one record marked Active='y'. As a result if I have 5 records in the join table with one marked as active then a query on the emp table for a unique empId will give me 5 same records with the nested role object.
[b]Is there a way to give conditions to the join table or can I use some sort of inheritance to fix this.[/b]
|