我有這樣的本地SQL請求:轉換本地SQL到JPQL與內部聯接
SELECT LMC_PARAMETRE.* FROM LMC_PARAMETRE
INNER JOIN INTERVENTION ON INTERVENTION.ID_INTV = LMC_PARAMETRE.ID_INTV
INNER JOIN REF_SITE ON INTERVENTION.DID_SITE =REF_SITE.ID_SITE
WHERE INTERVENTION.DCD_STATUT_INTV = '0' AND REF_SITE.ID_CENT = '097';
我喜歡把它轉換成JPQL但「ON」鍵字是不被認可:
JpaQueryBuilder builder = new JpaQueryBuilder();
builder.append("SELECT lmp FROM "+LmcParametre.class.getName()+" AS lmp ");
builder.append("INNER JOIN "+Intervention.class.getName()+" AS intv ON ");
builder.append("intv.idIntv = lmp.intervention.idIntv ");
builder.append("INNER JOIN "+Site.class.getName()+" AS site ON ");
builder.append("intv.didSite = site.idSite ");
builder.append("WHERE ");
builder.append(lt("intervention.statutIntv", String.valueOf(constanteInferieurePretACharger)));
builder.append("site.centre.idCent = "+idCentre);
根據HQL文檔:HQL中的連接是通過使用實體之間的關聯完成的。 但是我不明白這意味着什麼。
感謝