org.hibernate.hql.ast.QuerySyntaxException: XXX is not mapped 因为 String sql2 = "select s from Student s where s.clazz.name=:name"; 此处的 Student 应该为类名。hql语法里面是POJO对象而不是table