Estou com um problema na hora de setar um valor na `query.setParameter`. Uso *EcliseLink* e MySQL, fiz uma consulta sem setar parâmetros e funcionou, o que será que pode ser? Classe onde tento fazer a consulta: /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package br.com.redew.dao; import br.com.redew.entidade.Funcionario; import java.io.Serializable; import javax.persistence.NoResultException; import javax.persistence.NonUniqueResultException; import javax.persistence.Query; /** * * @author Desenvolvimento */ public class FuncionarioDao extends GenericoDao<Funcionario, Integer> implements Serializable { public Funcionario autenticar(Funcionario funcionario) throws NoResultException, NonUniqueResultException { Query query = getEm().createNamedQuery("Funcionario.autenticar"); query.setParameter("email", funcionario.getEmail()); query.setParameter("senha", funcionario.getSenha()); return (Funcionario) query.getSingleResult(); } } Classe GenericoDao: /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package br.com.redew.dao; import java.io.Serializable; import java.lang.reflect.ParameterizedType; import java.util.List; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.Persistence; import javax.persistence.Query; /** * * @author weder */ public class GenericoDao<T, ID> implements Serializable { private EntityManagerFactory emf; private EntityManager em; private Class<T> classe; public GenericoDao() { emf = Persistence.createEntityManagerFactory("br.com.redew_redew_war_1.0.0PU"); em = emf.createEntityManager(); classe = (Class<T>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0]; } public T find(ID id) { return getEm().find(classe, id); } public Object insert(T Objeto) { getEm().getTransaction().begin(); getEm().persist(Objeto); getEm().flush(); getEm().getTransaction().commit(); return Objeto; } public Object update(T Objeto) { getEm().getTransaction().begin(); getEm().merge(Objeto); getEm().flush(); getEm().getTransaction().commit(); return Objeto; } public Object delete(T Objeto) { getEm().getTransaction().begin(); getEm().remove(Objeto); getEm().flush(); getEm().getTransaction().commit(); return Objeto; } public List callNamedQuery(String namedQuery) { Query q = getEm().createNamedQuery(namedQuery); return q.getResultList(); } public List callNativeNamedQuery(String query) { Query q = getEm().createNativeQuery(query); return q.getResultList(); } public EntityManager getEm() { return em; } } Dá esse erro: > Caused by: javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.1.v20150605-31e8258): org.eclipse.persistence.exceptions.DatabaseException Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed. Error Code: 0 Call: SELECT id, email, nome, senha, telefone, id_empresa FROM funcionario WHERE ((email = ?) AND (senha = ?)) bind => [2 parameters bound] Query: ReadAllQuery(name="Funcionario.autenticar" referenceClass=Funcionario sql="SELECT id, email, nome, senha, telefone, id_empresa FROM funcionario WHERE ((email = ?) AND (senha = ?))")