【发布时间】:2014-05-18 21:44:47
【问题描述】:
Caused by: java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager:
Exception Description: Error compiling the query [select t from Utilisateur t where LOGIN='' and PASSWORD=''], line 1, column 34: unknown identification variable [login]. The FROM clause of the query does not declare an identification variable [login].
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1477)
at ejbservice.GestionUtulisateur.authentification(GestionUtulisateur.java:79)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
我的错误是什么,请帮助我,这是我的方法
public boolean authentification(String login, String password) {
String a = "select t from Utilisateur t where LOGIN='"+login+"' and PASSWORD='"+password+"'";
EntityManagerFactory emf = Persistence.createEntityManagerFactory("ProjetPU");
EntityManager em = emf.createEntityManager();
Query query = em.createQuery(a);
List <Utilisateur> Loaded = query.getResultList();
if ((Loaded.size())==0 ){
return false ;
} else {
return true;
}
}
【问题讨论】:
-
LOGIN和PASSWORDproperty 是 Utilisateur 的名称吗?如果是,您应该使用t.LOGIN、t.PASSWORD。