2009-02-25 81 views
0

我想要一个单一的HQL查询,它返回包含给定用户的所有组,该组在给定日期之前创建。不知何故,我无法做到。如何为此编写HQL查询?

public class Group 
{ 
    @ManyToMany 
    Set<User> users; 
    Date created; 
} 

public class User 
{ 
... 
} 

回答

0

II-Bhima的答案基本上是正确的 - 这里是一个小的修复:

select g from Group as g 
inner join g.users as user 
where g.created < :createdDate 
and user = :user 

你需要它,以便组返回,而不是与集团用户2元组对象[]。