jpa - CDI EntityManager fail -


hibernate says "an exception thrown hibernate means have rollback database transaction , close session immediately".

when persist method throws sqlexception , entitymanager becomes dirty, if close entitymanager, still in conversation scope.

i'm using: tomcat 7, cdi 1.1, hibernate 4.1;

is there way produce new entitymanager current conversation replace dirty?

@produces @conversationscoped public entitymanager create(entitymanagerfactory emf) {     entitymanager em = emf.createentitymanager();  ... 

viewbean

@named @conversationscoped  public class myview implements serializable { enter code here @inject @getter private entitymanager em; ... public void persist(){     try{         getem().gettransaction().begin();         getem().persist(entityinstance);         getem().gettransaction().commit();     }catch(exception e){         e.printstacktrace();         if(getem().gettransaction().isactive()){             getem().gettransaction().rollback();         }     } } 

no, there not. conversation scoped isn't scope entitymanager anyway. should request or default due transaction boundaries.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -