相关疑难解决方法(0)

HQL意外的AST节点:{vector}

我正在尝试编写一个HQL查询来获取属于特定组织的用户列表,或者来自特许经营者列表中的任何特许经营者,但是hibernate无法解析它.我无法弄清楚为什么.这是HQL:

from User u where 
(u.parentOrganisation = :topLevelOrganisation or u.parentOrganisation in :franchisees) 
and u.parentOrganisation.deleted = false 
and u.active = true
Run Code Online (Sandbox Code Playgroud)

这是hibernate吐出的错误:

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]
Run Code Online (Sandbox Code Playgroud)

如果我取出这个or u.parentOrganisation in …

java grails hibernate hql

9
推荐指数
2
解决办法
2万
查看次数

在JPQL查询中的集合上检查NULL?

我正在写一个JPQL查询,它基于Categories集合进行查询。我的类别可以为空,因此我正在使用:categories = NULL进行检查。

@Query("Select v from Vendor v join v.org vorg join v.categories cats WHERE vorg.email =:email AND (cats in :categories or :categories = NULL)")
Set<Vendor> filterVendors(@Param("emailId") String emailId, @Param("categories") Set<Category> categories);
Run Code Online (Sandbox Code Playgroud)

当类别为NULL时,以上方法可以正常工作。但是,当类别超过一个值时,我得到了错误

java.sql.SQLException:操作数应包含1列

与休眠有关的痕迹是

(?,?)或(?,?)中的category6_.category_id为null)

如何在JPQL中检查集合的null?我认为解决该问题应该可以解决此错误。任何帮助表示赞赏

谢谢。

java mysql hibernate jpa jpql

5
推荐指数
3
解决办法
2934
查看次数

标签 统计

hibernate ×2

java ×2

grails ×1

hql ×1

jpa ×1

jpql ×1

mysql ×1