有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何为此编写HQL查询?

我想要一个HQL查询,返回包含给定用户的所有组,这些用户是在给定日期之前创建的。不知怎么的,我做不好

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

public class User
{
...
}

共 (1) 个答案

  1. # 1 楼答案

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

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

    您需要它,以便返回组,而不是带有组用户2元组的对象[]