Hi everybody,
I am facing some problem from composite ManyToOne mapping below. The codes have no problem for compiling, but I got nothing from the SQLs below. Anybody can help me check whether the mapping models have some problem. I do appreciate it. Happy holiday for everybody! (Hibernate 3.3.1)
select distinct ppr from PersonProjectRole ppr where ppr.parent.person.id =:personId and ppr.parent.project.id =:projectIdCode:
public class PersonProject implements Serializable {
@EmbeddedId
private PersonProjectPK pk;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "PERSON_ID", insertable = false, updatable = false)
private Person person;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "PROJECT_ID", insertable = false, updatable = false)
private Project project;
@OneToMany(mappedBy="parent", cascade=CascadeType.ALL, fetch=FetchType.LAZY)
@IndexColumn(name = "ROLE_ID", base = 0)
private List<PersonProjectRole> roles;
....
}
@Embeddable
public class PersonProjectPK implements Serializable {
private Long personId;
private Long projectId;
...
}
public class PersonProjectRole implements Serializable {
@EmbeddedId
private PersonProjectRolePK pk;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumns({
@JoinColumn(name="PERSON_ID", insertable = false, updatable = false),
@JoinColumn(name="PROJECT_ID", insertable = false, updatable = false)
})
private PersonProject parent;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "ROLE_ID", insertable = false, updatable = false)
private Role role;
}
@Embeddable
public class PersonProjectRolePK implements Serializable {
private Long personId;
private Long projectId;
private Long roleId;
...
}