Skip to content
Advertisement

Hibernate : self join confusion?

I have a category table.In which first 5 are main category and others are sub category.

enter image description here

I need to fetch the sub categories of first 5 main category so i have found the sql query

JavaScript

The query is joining the same table itself.and am getting the result given below

Result

enter image description here

How can i convert the SQL query to HQL and return the data like above image to user in standard json format ?

FetchSubCategory

JavaScript

Method

JavaScript

Can any one please correct my mistake and tell me how to fetch result like above image?

Advertisement

Answer

This stuff will solve your problem

JavaScript

Get your sub categories

JavaScript
Advertisement