Hibernate HQL连接问题

Hibernate HQL连接问题,hibernate,join,hql,Hibernate,Join,Hql,我有两个班:教室,学生 HQL如何选择所有学生都叫John的教室?试试看 from ClassRoom inner join Student as student where student.name = 'John' 您需要为类使用完全限定的名称空间名称 此外,如果名称来自客户端,则应使用参数,例如:name选项1: select distinct ClassRoom from Student where Name = 'John' 备选案文2: from ClassRoom c wher

我有两个班:教室,学生

HQL如何选择所有学生都叫John的教室?

试试看

from ClassRoom inner join Student as student where student.name = 'John'
您需要为类使用完全限定的名称空间名称

此外,如果名称来自客户端,则应使用参数,例如:name

选项1:

select distinct ClassRoom
from Student
where Name = 'John'
备选案文2:

from ClassRoom c
where c in (select ClassRoom
            from Student
            where Name = 'John')

顺便说一下,这是非常基本的HQL。您应该浏览一下Care中的文档以详细说明?我在目前正在进行的一个项目中使用了与此非常类似的HQL,它执行得很好。
from ClassRoom c
where c in (select ClassRoom
            from Student
            where Name = 'John')