如何在多对多关联中使用hibernate来检索数据

时间:2017-03-23 12:45:41

标签: hibernate

我一直在关注这个[教程] [1]

[1]:http://www.codejava.net/frameworks/hibernate/hibernate-many-to-many-association-with-extra-columns-in-join-table-example我能够成功保存数据。现在我必须根据组和额外的列检索用户数据。例如,使用group =' value'和registered_date ='日期值'

有人可以指导我吗?

由于

1 个答案:

答案 0 :(得分:1)

SELECT userGroup.group_id.name AS groupName, userGroup.user_id.username AS username FROM user_group userGroup WHERE userGroup.user_id = 1 AND userGroup.group_id.name = 'someGroupName' AND userGroup.register_date = '2017 March 23 23:34:45'