I have two following Java entities
@Entity(table="user_profiles")
class Profile{
@Column(name="id")
@Id
@GeneratedValue
private Integer id;
@Column(name="first_name")
private String firstName;
@Column(name="last_name")
private String lastName;
}
And
@Entity
@Table(name="threads")
class Thread {
@Column(name="thread_id")
@Id
@GeneratedValue
private Integer threadId;
@Column(name="to_profile_name")
private String toProfileFullName;
@Column(name="from_profile_name")
private String fromProfileFullName;
@Column(name="to_profile_id")
private Integer toProfileId;
@Column(name="from_profile_id")
private Integer fromProfileId;
}
I need to populate toProfileFullName and fromProfileFullName with firstName+lastName of Profile class, fromProfileId and toProfileId are foreign keys of Profile class, is there any way using HQL? or with Hibernate relationship?