可以说我有两张桌子(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执行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)