I use the usertransaction for CMP entity beans, and I must say it really 
works...  I have also readed on the internet that userTransactions are only for 
session beans.  So I don't have a clue why it works with me.

below the code of my action, of my struts application

  | 
  | public ActionForward update(ActionMapping mapping,
  |                                             ActionForm form,
  |                                             HttpServletRequest request,
  |                                             HttpServletResponse response)
  | throws Exception{
  |     
  |     Context context = new InitialContext();
  |     UserTransaction userTran = 
(UserTransaction)context.lookup("UserTransaction");
  |     try{
  |             
  |             InitialenForm initialenForm = (InitialenForm)form;
  |             userTran.begin();
  | 
  |             Object ref = context.lookup("Initiaal");
  |             InitialenHomeRemote home = 
(InitialenHomeRemote)PortableRemoteObject.narrow(ref, 
InitialenHomeRemote.class);
  |             
  |             home.create("NOT","NOT","NOT","NOT","NOT");
  |             
  |             InitialenRemote initiaal = 
home.findByPrimaryKey(initialenForm.getId());
  |             initiaal.update(initialenForm.getInitiaal(),
  |                                             initialenForm.getNaam(),
  |                                             initialenForm.getDienst(),
  |                                             initialenForm.getInterneEmail(),
  |                                             initialenForm.getTelefoon(),
  |                                             
initialenForm.getLockIndicator());
  |             initialenForm.setLockIndicator(initiaal.getLockindicator());
  |             
  |             
  |             userTran.commit();
  |             
  |             ActionMessages messages = new ActionMessages();
  |             messages.add("initiaal",new 
ActionMessage("initiaal.successvol.opgeslaan", initialenForm.getInitiaal()));
  |             saveMessages(request,messages);
  |     }catch(ActionException e){
  |             userTran.rollback();
  |             saveExceptions(request,e);
  |     }catch(Exception ex){
  |             userTran.rollback();
  |             throw ex;
  |     }
  |     return mapping.findForward(IConstants.INPUT_KEY);
  | }
  | 

My update method of my bean throws an ActionException (selfmade -exception) 
when the name is empty.

So when initialenForm.getNaam() is empty, I get a ROLLBACK.  And when I check 
my MySQL database, I see that the home.create("NOT","NOT","NOT","NOT","NOT"); 
is also rollback.

Strange!!!

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

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


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to