Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/388.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java JPQL(EclipseJPAProcider)无法对int调用方法_Java_Sql Server_Eclipse_Jpa - Fatal编程技术网

Java JPQL(EclipseJPAProcider)无法对int调用方法

Java JPQL(EclipseJPAProcider)无法对int调用方法,java,sql-server,eclipse,jpa,Java,Sql Server,Eclipse,Jpa,因此,我在Netbean JPQL工具中使用了以下JPQL SELECT e.idEtu, e.nomEtu, e.prenomEtu,e.ddnEtu FROM Etudiant e,InscrireClasse i, Niveau n WHERE i.idNiveau = n.idNiveau AND n.nomNiveau='Master 1' 当我运行它时,我不知道为什么,但是有一个Bug。下面是JPA日志(它说不能在int上调用方法…不知道它是什么意思) 如果我在没有I.idN

因此,我在Netbean JPQL工具中使用了以下JPQL

SELECT e.idEtu, e.nomEtu, e.prenomEtu,e.ddnEtu 
FROM Etudiant e,InscrireClasse i, Niveau n 
WHERE i.idNiveau = n.idNiveau  AND n.nomNiveau='Master 1'
当我运行它时,我不知道为什么,但是有一个Bug。下面是JPA日志(它说不能在int上调用方法…不知道它是什么意思)

如果我在没有I.idNiveau=n.idNiveau的情况下运行它,它工作得非常好

javax.persistence.PersistenceException: Exception [EclipseLink-4002]    (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd):    org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.microsoft.sqlserver.jdbc.SQLServerException:     Cannot call methods on int.
Error Code: 258
Call: SELECT t0.id_etu, t0.nom_etu, t0.prenom_etu, t0.ddn_etu FROM     GESTION_DES_NOTES.dbo.etudiant t0, GESTION_DES_NOTES.dbo.niveau t2, GESTION_DES_NOTES.dbo.InscrireClasse t1 WHERE ((t1.id_niveau = t2.id_niveau.t2.id_niveau) AND (t2.nom_niveau = ?))
bind => [1 parameter bound]
Query: ReportQuery(referenceClass=Etudiant sql="SELECT t0.id_etu,  t0.nom_etu, t0.prenom_etu, t0.ddn_etu FROM GESTION_DES_NOTES.dbo.etudiant t0, GESTION_DES_NOTES.dbo.niveau t2, GESTION_DES_NOTES.dbo.InscrireClasse t1 WHERE ((t1.id_niveau = t2.id_niveau.t2.id_niveau) AND (t2.nom_niveau = ?))")
at org.eclipse.persistence.internal.jpa.QueryImpl.getDetailedException(QueryImpl.java:378)
at org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:260)
at org.eclipse.persistence.internal.jpa.QueryImpl.getResultList(QueryImpl.java:469)
Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.microsoft.sqlserver.jdbc.SQLServerException:        Cannot call methods on int.
    Error Code: 258
Call: SELECT t0.id_etu, t0.nom_etu, t0.prenom_etu, t0.ddn_etu FROM GESTION_DES_NOTES.dbo.etudiant t0, GESTION_DES_NOTES.dbo.niveau t2, GESTION_DES_NOTES.dbo.InscrireClasse t1 WHERE ((t1.id_niveau = t2.id_niveau.t2.id_niveau) AND (t2.nom_niveau = ?))
bind => [1 parameter bound]
Query: ReportQuery(referenceClass=Etudiant sql="SELECT t0.id_etu, t0.nom_etu, t0.prenom_etu, t0.ddn_etu FROM GESTION_DES_NOTES.dbo.etudiant t0, GESTION_DES_NOTES.dbo.niveau t2, GESTION_DES_NOTES.dbo.InscrireClasse t1 WHERE ((t1.id_niveau = t2.id_niveau.t2.id_niveau) AND (t2.nom_niveau = ?))")
at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:340)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:682)
...
如果我试着转换位置写n.idNiveau=I.idNiveau而不是I.idNiveau=n.idNiveau

Local Exception Stack: 
Exception [EclipseLink-6076] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.QueryException
Exception Description: Object comparisons can only be used with    OneToOneMappings.  Other mapping comparisons must be done through query keys or direct attribute level comparisons. 
Mapping:   [org.eclipse.persistence.mappings.DirectToFieldMapping[idNiveau-->GESTION_DES_NOTES.dbo.niveau.id_niveau]] 
Expression: [
Query Key idNiveau
 Base Entity_classes.Niveau]
Query: ReportQuery(referenceClass=Etudiant jpql="SELECT e.idEtu, e.nomEtu, e.prenomEtu,e.ddnEtu 
来自美国纽约州尼维尔市一级研究生教育学院
其中,n.idNiveau=i.idNiveau和n.nomNiveau='Master 1')

您是否有一个属性
inscrirecase.niveau
?@wero Nope.在inscrirecase类中,我有一个属性idNiveau_uuuu',而niveau是另一个属性为idNiveau和nom_niveau的类。(idNiveau是Niveau中的主键,INSCRIRIRECLASSE中的引用键或外键)没有这些类,谁能对此发表评论?@NeilStockton Ouch我很失望,删除了这个项目。我自己找不到任何东西。