0
我正在一個項目中,我必須生成一個HQL查詢以在JEE項目中完成任務。我的HQL查詢是:SQL開發人員返回結果,而HQL返回錯誤
requete.append("SELECT elec, MIN(tour.datScrutin) dat FROM HbEleElection elec, HbEleTourScrutin tour");
requete.append(" WHERE elec.idEtaElection <> "+ cstRepository.getIdConstanteByLibelle("ETAT_ELECTION_TERMINEE"));
requete.append(" AND elec.id = tour.idElection");
requete.append(" AND elec.zzzDsuEng is null");
requete.append(" GROUP BY elec.lbcElection");
requete.append(" ORDER BY dat ");
但沒有得到任何結果。
我設法清理的東西,這是我的SQL開發人員的SQL查詢返回我想要的結果。
SELECT elec.lbc_election,
MIN(tour.dat_Scrutin) dat
FROM Ele_Election elec,
Ele_Tour_Scrutin tour
WHERE elec.id_Eta_Election <> 335
AND elec.id_election = tour.id_Election
AND elec.zzz_Dsu_Eng IS NULL
GROUP BY elec.lbc_Election
ORDER BY dat desc
與我的HQL的java我得到這個錯誤的HQL:
1 net.sf.hibernate.QueryException:,預計將在選擇[選擇ELEC,MIN(tour.datScrutin)DAT FROM vdm.commun.scrutin.dao.hbbean.HbEleElection as elec,vdm.commun.scrutin.dao.hbbean.HbEleTourScrutin tour WHERE elec.idEtaElection <> 335 AND elec.id = tour.idElection AND elec.zzzDsuEng is null GROUP BY elec.lbcElection ORDER BY dat]