[jboss-user] [JBoss Seam] - Re: Rollback exceptions without ending the conversation

enazareno do-not-reply at jboss.com
Wed Mar 7 21:37:59 EST 2007


Hi,

    Thanks for pointing that out. Here is my sample code

  |     @In
  |     EntityManager em;
  | 
  |     @In
  |     UserList userList;
  | 
  |     boolean isnew;
  | 
  |     @Out
  |     User user;
  | 
  |     @Begin( id="#{user.id}" )  
  |     public void edit() {
  |         user = em.merge(userList.getSelectedUser());
  |         isnew = false;
  |     }
  | 
  |     @End
  |     public void save() {
  |         if(isnew) 
  |             em.persist( user );
  |         else
  |             em.merge( user );
  |         userList.refresh();  //can also use event for this
  |         isnew = false;
  |     }
  | 

    The conversation actually ends when I press save. However it is my understanding that you cant put a try catch inside the save because the entity manager is flushed only when it ends so at this point there is no error yet? Is this correct? Let's say I'll just accept that limitation and I want to create another conversation instead. I've already specified the conversation id, can't I just use that as a reference to my new conversation that I will create? Or is there no chance to get back to that conversation? 

     I agree with you, this seems like a complex solution and I'd prefer number one too. It just kinda reminds me of the old days developing Clipper applications where you manage this kind of validation yourself. With client-server development, you are encouraged to let the database handle this. Now its back. Life's a cycle isnt it? so retro :)


Regards,

Elmo     


     


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4026081#4026081

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4026081



More information about the jboss-user mailing list