grails 中的 HQL 查询语法

发布于 2024-12-11 14:57:39 字数 634 浏览 0 评论 0原文

我正在尝试获取具有多个“教育”的员工列表,每个“教育”都有一个“教育类型”,

因此员工有一个教育集合,每个教育都有一个有名称的类型。

    def unchecked = educationTypes?.unchecked
    String query = "FROM Employee e, IN (e.education)  AS ed WHERE ed.type.name IN (:typeNames)";

    def matches = Employee.executeQuery(query, [typeNames: unchecked]);

上面的查询给了我以下内容:

Stacktrace follows:
org.hibernate.hql.ast.QuerySyntaxException: unexpected token: ed near line 1, column 39 [FROM Employee e, IN (e.education)  AS ed WHERE ed.type.name IN (:typeNames)]
    at $Proxy12.createQuery(Unknown Source)

所以我试图找出如何正确访问它。非常感谢任何帮助

I am trying to get a list of employees that have multiple "Education" which each have an "Education type"

so Employee has a collection of educations, which each have an type which have a name.

    def unchecked = educationTypes?.unchecked
    String query = "FROM Employee e, IN (e.education)  AS ed WHERE ed.type.name IN (:typeNames)";

    def matches = Employee.executeQuery(query, [typeNames: unchecked]);

The query above give me the following:

Stacktrace follows:
org.hibernate.hql.ast.QuerySyntaxException: unexpected token: ed near line 1, column 39 [FROM Employee e, IN (e.education)  AS ed WHERE ed.type.name IN (:typeNames)]
    at $Proxy12.createQuery(Unknown Source)

So I am trying to figure out how to access this correctly. Much appreciation for any help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

若言繁花未落 2024-12-18 14:57:39

尝试这样的事情:

Employee.executeQuery("""
    select e from Employee e, Education ed 
    where ed.employee = e and ed.type.name IN (:typeNames)
""", [typeNames: [...]])

Try something like this:

Employee.executeQuery("""
    select e from Employee e, Education ed 
    where ed.employee = e and ed.type.name IN (:typeNames)
""", [typeNames: [...]])
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文