0
JPA/Hibernateを使用しています リストアを行うためにcreatequeryを使用する方法を知りたいのですが、オブジェクトクエリ言語を使用してクエリから結果リストを取得する方法
EntityManagerFactory emf=Persistence.createEntityManagerFactory("JiraMapPUKPI");
EntityManager em= emf.createEntityManager();
EntityTransaction entr=em.getTransaction();
entr.begin();
Query multipleSelect =em.createQuery("select distinct k.kpiName FROM Kpi k ,ProfilUser p ,AssociationKpiProfil a WHERE p.profilUserId= :w and p.profilUserId= a.profilUser and a.kpi=k.kpiId ").setParameter("w", userid);
をしかし、私は使用しカント:: 私が試してみました
List userList = (List)multipleSelect.getResultList();
multipleSelectはgetResultList方法
を含んではいけないと私も試してみましたので:
javax.persistence.Query multipleSelect= em.createQuery("select k.kpiName FROM Kpi k ,ProfilUser p ,AssociationKpiProfil a WHERE p.profilUserId= :w and p.profilUserId= a.profilUser and a.kpi=k.kpiId ");
multipleSelect.setParameter("w", userid);
List usrpro= multipleSelect.getResultList();
しかし、これをエラーが表示されます:
EL Warning]: 2011-06-21 08:53:08.81--UnitOfWork(6850900)--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.2.0.v20110202-r8913): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')) AND (t3.KPI_ID = t0.KPI_ID.t0.KPI_ID)) AND (t2.PROFIL_USER_ID = t3.PROFIL_ID)' at line 1
Error Code: 1064
Call: SELECT t0.KPI_NAME FROM association_kpi_profil t3, profil_user t2, profil_user , kpi t0 WHERE ((((t1.PROFIL_USER_ID = ?) AND (t1.PROFIL_USER_ID =)) AND (t3.KPI_ID = t0.KPI_ID.t0.KPI_ID)) AND (t2.PROFIL_USER_ID = t3.PROFIL_ID))
bind => [1 parameter bound]
Query: ReportQuery(referenceClass=Kpi sql="SELECT t0.KPI_NAME FROM association_kpi_profil t3, profil_user t2, profil_user t1, kpi t0 WHERE ((((t1.PROFIL_USER_ID = ?) AND (t1.PROFIL_USER_ID =)) AND (t3.KPI_ID = t0.KPI_ID.t0.KPI_ID)) AND (t2.PROFIL_USER_ID = t3.PROFIL_ID))")
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')) AND (t3.KPI_ID = t0.KPI_ID.t0.KPI_ID)) AND (t2.PROFIL_USER_ID = t3.PROFIL_ID)' at line 1
Error Code: 1064
Call: SELECT t0.KPI_NAME FROM association_kpi_profil t3, profil_user t2, profil_user t1, kpi t0 WHERE ((((t1.PROFIL_USER_ID = ?) AND (t1.PROFIL_USER_ID =)) AND (t3.KPI_ID = t0.KPI_ID.t0.KPI_ID)) AND (t2.PROFIL_USER_ID = t3.PROFIL_ID))
bind => [1 parameter bound]
Query: ReportQuery(referenceClass=Kpi sql="SELECT t0.KPI_NAME FROM association_kpi_profil t3, profil_user t2, profil_user t1, kpi t0 WHERE ((((t1.PROFIL_USER_ID = ?) AND (t1.PROFIL_USER_ID =)) AND (t3.KPI_ID = t0.KPI_ID.t0.KPI_ID)) AND (t2.PROFIL_USER_ID = t3.PROFIL_ID))")
errrrrs
list kpiiiiiiiinull
どうすればいいですか? ありがとうございました
こんにちは、エラーは私のSQL要求:)ではなく、p.profilUserId = a.profilUserそれはp = a.profilUserする必要があります – ramram