1
我得到了這個請求:JPA - 加入對同桌
TypedQuery<ParamGenerauxExternes> q = entityMgr
.createQuery("SELECT p FROM ParamGenerauxExternes p "
+ "WHERE EXISTS "
+ "(SELECT q FROM ParamGenerauxExternes q "
+ "WHERE q.key.origine = :pOrigine "
+ "AND q.key.typeParam LIKE :pTypeParametreBis "
+ "AND p.key.sousType LIKE CONCAT('%',q.libelleParam) "
+ "AND q.actif = 'Y') "
+ "ORDER BY p.libelleParam", ParamGenerauxExternes.class)
//.setParameter("pTypeParametre", "REL_TO_HOUSEHOLD")
.setParameter("pOrigine", pOrigineGrc)
.setParameter("pTypeParametreBis", "GRC_HOUSEHOLD_TYPE_P%");
但它不工作,我得到這個錯誤消息告訴prenthesis丟失:
GRAVE: EJB Exception: : javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: ORA-00907: missing right parenthesis
生成的SQL通過JPA有後的第二個括號中進行選擇:
select
paramgener0_.CODE_PARAM as CODE1_2823_,
paramgener0_.ORIGINE as ORIGINE2823_,
paramgener0_.SOUS_TYPE as SOUS3_2823_,
paramgener0_.TYPE_PARAM as TYPE4_2823_,
paramgener0_.ACTIF as ACTIF2823_,
paramgener0_.LIBELLE_PARAM as LIBELLE6_2823_
from
FOA_PARAM_GEN_EXTERNE paramgener0_
where
exists (
select
(paramgener1_.CODE_PARAM,
paramgener1_.ORIGINE,
paramgener1_.SOUS_TYPE,
paramgener1_.TYPE_PARAM)
from
FOA_PARAM_GEN_EXTERNE paramgener1_
where
paramgener1_.ORIGINE=?
and (
paramgener1_.TYPE_PARAM like ?
)
and (
paramgener0_.SOUS_TYPE like '%'||paramgener1_.LIBELLE_PARAM
)
and paramgener1_.ACTIF='Y'
)
order by
paramgener0_.LIBELLE_PARAM
我不知道爲什麼冬眠第二後加括號?請如果你知道該怎麼辦...