HQL意外的AST节点:{vector} [英] HQL unexpected AST node: {vector}

查看:148
本文介绍了HQL意外的AST节点:{vector}的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图编写HQL查询来获取属于特定组织的用户列表,或者从特许经营商列表中选择任何特许经营商,但是hibernate无法解析它。我无法弄清楚为什么。这里是HQL:

I'm trying to write an HQL query to grab a list of users that belong to a particular organisation, or any franchisee from a list of franchisees, however hibernate isn't able to parse it. I can't figure out why. Here is the HQL:

from User u where 
(u.parentOrganisation = :topLevelOrganisation or u.parentOrganisation in :franchisees) 
and u.parentOrganisation.deleted = false 
and u.active = true



This is the error that hibernate spits out:

unexpected AST node: {vector} [from com.myapp.User u where (u.parentOrganisation = :topLevelOrganisation or u.parentOrganisation in :franchisees0_, :franchisees
1_, :franchisees2_) and u.parentOrganisation.deleted = false and u.active = true]. Stacktrace follows:
Message: unexpected AST node: {vector} [from com.myapp.User u where (u.parentOrganisation = :topLevelOrganisation or u.parentOrganisation in :franchisees0_, :fr
anchisees1_, :franchisees2_) and u.parentOrganisation.deleted = false and u.active = true]

如果我取出或u.parentOrganisation在:franchisees 位,所以我的查询如下所示:

If I take out the or u.parentOrganisation in :franchisees bit, so my query looks like this:

from User u where 
(u.parentOrganisation = :topLevelOrganisation) 
and u.parentOrganisation.deleted = false 
and u.active = true

然后工作正常。我的语法有什么问题?为什么hibernate会抱怨额外的子句?

Then it works fine. What's wrong with my syntax? Why is hibernate complaining about that extra clause?

推荐答案

哦,事实证明我需要将 :加盟商在括号中:

Oh, it turns out that I needed to enclose :franchisees in parentheses:

from User u where 
(u.parentOrganisation = :topLevelOrganisation or u.parentOrganisation in (:franchisees)) 
and u.parentOrganisation.deleted = false 
and u.active = true

这篇关于HQL意外的AST节点:{vector}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆