Hello all,
I have a question regarding join between 2 entities using hql.
Starting on a userProfile, I have to retrieve the name of the role associated to this userProfile. So I need to make a join in order to get it in the role table.
I have the following class UserProfile :
Code:
@Entity
@Table(name="USER_PROFILES")
public class UserProfile extends VersionedObject implements Serializable {
public static final int CAID_LENGTH = 64;
@Column(nullable=false, length=CAID_LENGTH)
private String caid;
@Column(length=255)
private String description;
@CollectionOfElements
@JoinTable(
name="USER_ROLES",
joinColumns={
@JoinColumn(name="user_id", referencedColumnName="id"),
@JoinColumn(name="user_v_no", referencedColumnName="v_no")
})
@Column(name="role_id")
private Set<Integer> roleIds;
Here is the Role.java class:
Code:
@Entity
@Table(name="ROLES")
public class Role extends VersionedObject implements Serializable {
@Column(nullable=false, length=255)
private String name;
@Column(length=255)
private String description;
@CollectionOfElements
@JoinTable(
name="ROLES_RIGHTS",
joinColumns={
@JoinColumn(name="role_v_no", referencedColumnName="v_no"),
@JoinColumn(name="role_id", referencedColumnName="id")
})
private Set<Right> rights;
Do you know how can I make a join based on the private Set<Integer> roleIds within the userProfile.java to retrieve the associated role in order to retrieve the name?
doesn't matter if it's using criteria or hql.
Thank you very much :)