java.lang.ClassCastException with the same class object
问题 This piece of code irritates me, sometimes it working and some other times it doesn't ! The NamedQuery : (name = "User.findByLogin", query = "SELECT u FROM User u WHERE u.login = :login") public User findByLogin(String login) { Query query = em.createNamedQuery("User.findByLogin"); query.setParameter("login", login); try { return (User) query.getSingleResult(); } catch (javax.persistence.NoResultException ex) { return null; } } The error make me crazy ! Avertissement: EJB5184: A system