whwwhw1980
whwwhw1980
2018-12-20 22:42

求助!!SQL语句怎样翻译成HQL

  • java
  • hibernate

1、sql语句:
SELECT
Mgr.id,
U.name AS applyname,
T.name,
U2.name AS frist_approvername,
U3.name AS second_approvername
FROM
mgr_business AS Mgr
LEFT JOIN mgr_business_type AS T ON Mgr.business_type_id = T.id
LEFT JOIN ac_user AS U ON Mgr.apply_user_id = U.id
LEFT JOIN ac_user AS U2 ON Mgr.first_approve_user_id = U2.id
LEFT JOIN ac_user AS U3 ON Mgr.second_approve_user_id = U3.id
2、变成Hql后:
SELECT
Mgr.Id,
U. NAME AS applyName,
Mgr.startDate,
Mgr.startdaypartId,
Mgr.endDate,
Mgr.enddaypartId,
T. NAME AS TypeName,
Mgr.businessstatusId,
Mgr.applyTime,
Mgr.applyRemark,
U2. NAME AS fristapprovername,
Mgr.firstapproverTime,
Mgr.firstapproverRemark,
U3. NAME AS secondapprovername,
Mgr.secondapproverTime,
Mgr.secondapproverRemark
FROM
TMgrBusiness AS Mgr
LEFT JOIN TType AS T ON Mgr.businesstypeId = T.Id
LEFT JOIN TAcUser AS U ON Mgr.applyuserId = U.Id
LEFT JOIN TAcUser AS U2 ON Mgr.firstapproveruserId = U2.Id
LEFT JOIN TAcUser AS U3 ON Mgr.secondapproveruserId = U3.Id

3、运行出错,网上说不能用JOIN ON ,请问该如何处理??谢谢!!

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答