Ola pessoal, o OpenSessionInView que implementei não está persistindo no banco, vejam o código abaixo.
[code]public class JPAUtil {
private static final EntityManagerFactory emf = Persistence.createEntityManagerFactory("Igreja");
public static EntityManager getEntityManager(){
return emf.createEntityManager();
}
public static void closeEntityManagerFactory(){
emf.close();
}
}[/code]
[code]@WebFilter(urlPatterns="/*")
public class FilterJPATransaction implements Filter {
@Override
public void doFilter(ServletRequest req, ServletResponse res,FilterChain chain) throws IOException, ServletException {
EntityManager em = JPAUtil.getEntityManager();
EntityTransaction tx = em.getTransaction();
try {
tx.begin();
chain.doFilter(req, res);
tx.commit();
} catch (Throwable e) {
if(tx != null && tx.isActive()){
tx.rollback();
}
}finally{
em.close();
}
}
@Override
public void init(FilterConfig arg0) throws ServletException {}
@Override
public void destroy() {
JPAUtil.closeEntityManagerFactory();
}
}[/code]
Quando do meu ManagedBean chamo o metodo abaixo nada é salvo no banco.
public Fiel salvar(Fiel fiel) throws Exception{
EntityManager em = JPAUtil.getEntityManager();
try {
Fiel fielAux = em.merge(fiel);
return fielAux;
} catch (Exception e) {
throw e;
}
}