I have a class for a login and when I login I get this:
com.logic.Teaching can not be converted to com.logic.Docente
I have tried to assign a variable to the session, however I get this error, I always have to restart the server and I've been in this for more than 3 weeks and it's already uncomfortable.
These are my methods.
/**
* *
* Metodo para login de docente
*
* @return la pagina redireccionando al docente al index
*/
public String loginUser() {
try {
TypedQuery<Docente> query = entityManager.createNamedQuery("Docente.Login", Docente.class);
query.setParameter("user", user);
query.setParameter("password", password);
if (query.getResultList().size() > 0) {
FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("userTeacherSesion", query.getResultList().get(0));
return "Views/IndexTeacher";
}
} catch (Exception e) {
System.out.println(e.getMessage());
}
message = "usuario o password incorrecta";
return "";
}
/**
* *
* metodo para obtener el id del docente
*
* @return El objeto con la sesion
*/
public Docente getDocenteSesion() {
return (Docente) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("userTeacherSesion");
}
Caused by: java.lang.ClassCastException: com.logic.Docente can not be cast to com.logic.Docente at com.controller.LoginController.getDocenteSesion (LoginController.java:120)