Hibernate条件连接两个表以从两个表中获取数据

Hibernate条件连接两个表以从两个表中获取数据,hibernate,Hibernate,在下面的场景中,我希望将两个表中的不同列提取到一个实体中: 实体1:表格->TBL\u讨论 public class Discussion{ private int discussionId;// primary key private int discussionText; private String createByUserId;// Foreign Key (TBL_USER.userId) private String createByUserFullName;// This is j

在下面的场景中,我希望将两个表中的不同列提取到一个实体中:

实体1:表格->
TBL\u讨论

public class Discussion{
private int discussionId;// primary key
private int discussionText;
private String createByUserId;// Foreign Key (TBL_USER.userId)
private String createByUserFullName;// This is just a property, and does not have   stored into table
private Timestamp createTimestamp;
}
实体2: 表->
TBL\u用户

public class User{
    private int userId;// primary key
    private int userFullName;
}
现在,我需要做的是,我必须从TBL_讨论中获取所有讨论,并为每个讨论创建者获取
UserFullName
,但我们只将
userId
createByUserId
)存储到
TBL_讨论
表中,用户的全名位于
TBL_用户
表中


如何编写实现这一目标的标准?

格式化代码,并阅读相关信息。讨论不应该有用户ID和用户全名,而应该有与用户的多通关联。正如@JBNizet所写,您不能将条件与联接一起使用,因为实体需要与正确的注释关联(例如,
manytone