请问java和数据库高手,下面的sql如何用hibernate的hql语句来替换啊?
SELECTs.*FROMbox_supplier_categorysINNERJOIN(SELECTs.idASsid,s.parent_idASspid,s2.idA...
SELECT s.*FROM box_supplier_category s INNER JOIN (SELECT s.id AS sid, s.parent_id AS spid, s2.id AS s2id, s.is_valid FROM box_supplier_category s LEFT JOIN box_supplier_category s2 ON s2.parent_id = s.id AND s2.is_valid = 1 WHERE s2.id IS NULL AND s.is_valid = 1) t ON s.id = t.spid UNION ALL SELECT s.*FROM box_supplier_category s LEFT JOIN box_supplier_category s2 ON s2.parent_id = s.id AND s2.is_valid = 1 WHERE s2.id IS NULL AND s.is_valid = 1 AND s.parent_id IS NULL ;因为sql查询只能查询出字段,无法查出对象,请问如何用hibernate的hql语句替换呢?其中box_supplier_category 对应一个对象
展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询