I'm performing a SQL query through hibernate, which looks like:
@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)")
But it showing me error
Caused by: java.lang.IllegalArgumentException: node to traverse cannot be null!
your query is fine at sql level, but in case of Hibernate you will face this exception
Caused by: java.lang.IllegalArgumentException: node to traverse cannot be null!
so convert this query
@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)")
into two queries
@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)")
@Query("select category from Category category where category.isDelete=false and category.status='A' and category.parentCategory IS NOT NULL")
and call them by different methods.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With