0
完整的錯誤信息:休眠錯誤 - QuerySyntaxException:管理員沒有映射錯誤
11:49:51,896 INFO [stdout] (http-localhost-127.0.0.1-8080-1) javax.ejb.EJBException: java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: administrator is not mapped [SELECT ad FROM administrator ad WHERE ad.adminID='123' AND ad.Password='123']
@Stateless
public class ManageAdministrator implements ManageAdministratorRemote {
@PersistenceContext(unitName = "JPADB")
private EntityManager entityManager;
public ManageAdministrator() {
}
public Administrator createAdministrator(Administrator adminID)
{
entityManager.persist(adminID);
System.out.println("Inside create administrator");
entityManager.flush();
return adminID;
}
public List retrieveAllAdministrators()
{
String q = "SELECT ad from " + Administrator.class.getName() + " ad";
Query query = entityManager.createQuery(q);
List administrators = (List) query.getResultList();
return administrators;
}
@Override
public Administrator adminLogin(Administrator adminID) {
try {
String q ="SELECT ad FROM administrator ad WHERE ad.adminID='"
+ adminID.getAdminID() +"'"
+ " AND ad.Password='"
+ adminID.getPassword() +"'";
Query query = entityManager.createQuery(q);
query.setMaxResults(1);
//query.setParameter("logInEmail", admin.getLogInEmail());
System.out.println(q);
return (Administrator) query.getSingleResult();
}
catch(NoResultException e)
{
return null;
}
}
@Override
public int stringToInt(String word) {
// TODO Auto-generated method stub
return 0;
}
可我知道什麼是此錯誤的原因是什麼?
persistence.xml中是管理類可用? –
確實,你可以發佈persistence.xml,spring配置和Administrator實體嗎? – ConMan