Boa tarde galera, estou tentando fazer um select aqui em jpa mas está dando o seguinte erro.. Os nomes do banco e campos está todos certos, o que pode estar acontecendo? Obrigado pela ajuda..
java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager:
Exception Description: Problem compiling [SELECT u FROM _user u WHERE u.email=:email AND u.password=:password]. [14, 19] The abstract schema type '_user' is unknown. [28, 35] The state field path 'u.email' cannot be resolved to a valid type. [49, 59] The state field path 'u.password' cannot be resolved to a valid type. at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1585) at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1605) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
O código para fazer o login é este.
public boolean validatePassword(User user) throws Exception {
String email = user.getEmail(); String pass = user.getPassword(); if (email == null || pass ==null) { throw new Exception("Invalid parameter User and/or Password"); } //MD 5 Encryption MessageDigest md = MessageDigest.getInstance("MD5"); md.reset(); byte[] encryptedBytes = md.digest(pass.getBytes()); StringBuffer pwdEncrypt = new StringBuffer(); for(int i=0;i<encryptedBytes.length;i++){ pwdEncrypt.append(Integer.toHexString(0xff & encryptedBytes[i])); } //Check into database the encrypted password as MD5 is one way boolean login = false; pass = pwdEncrypt.toString(); TypedQuery<User> query = em.createQuery("SELECT u FROM _user u WHERE u.email=:email AND u.password=:password", User.class); query.setParameter("email", user.getEmail()); query.setParameter("password", pass); if(query.getSingleResult() != null){ login = true; } return login; }