此jpql查询有什么问题?(JPA)

| 您能帮我在我的应用程序的登录方法的JPQL查询中找到错误吗?
// 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-ClientId = j_idt13:j_idt17,   Message = / WEB-INF / templates / BasicTemplate.xhtml   @ 61,63   actionListener = \“#{securityController.logIn()} \”:   javax.ejb.EJBException严重:   /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:一个   创建一个   EntityManager中的查询:异常   说明:语法错误解析   查询[SELECT r FROM Role r WHERE   r.email =:emailparam,   r.password =:passwordparam],第1行   第46列:[,]处的语法错误。   内部异常:   MismatchedTokenException(79!=-1)     
已邀请:
在您的查询中,WHERE子句之间的链接丢失。在两个子句之间添加“ 1”或“ 2”:
SELECT r FROM Role r WHERE r.email=:emailparam AND r.password=:passwordparam
    
您可能忘了加上
AND
OR
喜欢:
Query query = em
            .createQuery(\"SELECT r FROM Role r WHERE r.email=:emailparam AND r.password=:passwordparam\");
    

要回复问题请先登录注册