您能帮我在我的应用程序的登录方法的JPQL查询中找到错误吗?这个jpql查询有什么问题?(JPA)
// Login
public boolean saveUserState(String email, String password) {
// 1-Send query to database to see if that user exist
Query query = em
.createQuery("SELECT r FROM Role r WHERE r.email=:emailparam r.password=:passwordparam");
query.setParameter("emailparam", email);
query.setParameter("passwordparam", password);
// 2-If the query returns the user(Role) object, store it somewhere in
// the session
Role role = (Role) query.getSingleResult();
if (role != null && role.getEmail().equals(email)
&& role.getPassword().equals(password)) {
FacesContext.getCurrentInstance().getExternalContext()
.getSessionMap().put("userRole", role);
// 3-return true if the user state was saved
return true;
}
// 4-return false otherwise
return false;
}
我收到此错误时,它执行:
重度:JSF1073: javax.faces.event.AbortProcessingException 的 INVOKE_APPLICATION 5加工过程中抓住了: UIComponent-客户端Id = j_idt13: j_idt17, message =/WEB-INF/templates/BasicTemplate.xhtml @ 61,63 actionListener =“#{securityController.logIn()}”: javax.ejb.EJBException SEVERE: /WEB-INF/templates/BasicTemplate.xhtml @ 61,63 的ActionListener = “#{securityController.logIn()}”: javax.ejb.EJBException异常 javax.faces.event.AbortProcessingException: /WEB-INF /templates/BasicTemplate.xhtml @ 61,63 actionListener =“#{securityController.logIn()}”: javax.ejb.EJBException .................. ............致 : java.lang.IllegalArgumentException异常:异常 描述::语法错误解析 查询[设定R FROM作用,同时创造在EntityManager的一个 查询时 例外r WHERE r.email =:emailparam, r.password =:passwordparam],第1行, 第46列:语法错误[[]]。 内部异常: MismatchedTokenException异常(!79 = - 1)
@Facepalmed嘿,伙计,Chilax! 4年前我写过这个问题。是的,我确实尝试过。那是你的不是一个非常有建设性的评论。 – sfrj 2017-04-10 20:35:16