相关疑难解决方法(0)

在HQL中无需关联即可加入

可以说我有两张桌子(A,B),如:

A {id, a, c}
B {id, b, c}
Run Code Online (Sandbox Code Playgroud)

我也有他们的实体.我想编写一个HQL,以便结果集就像(其中Ac = Bc):

(a1, b1, c1)
(a2, b2, c2)
(a3, b3, c3)
...
Run Code Online (Sandbox Code Playgroud)

由于onhibernate不支持子句,我被卡住了,我不知道如何编写查询.

hibernate join hql

38
推荐指数
1
解决办法
4万
查看次数

如何在hibernate中使用UNION执行查询

我正在通过hibernate执行SQL查询,它看起来像:

@Query("(select category from Category category where category.isDelete=false and category.status='A' AND " +
        "category.id in (select cat.id from Category cat where cat.isDelete=false and cat.status='A' and cat.parentCategory IS NOT NULL))" +
        "UNION" +
        "(select category from Category category where category.isDelete=false and category.status='A' and category.parentCategory IS NOT NULL)")
Run Code Online (Sandbox Code Playgroud)

但它显示我的错误

Caused by: java.lang.IllegalArgumentException: node to traverse cannot be null!
Run Code Online (Sandbox Code Playgroud)

java mysql hibernate spring-boot

6
推荐指数
1
解决办法
1928
查看次数

标签 统计

hibernate ×2

hql ×1

java ×1

join ×1

mysql ×1

spring-boot ×1