hello!

i have jboss-4.2.3GA and example from jboss-seam-2.1.1.GA sources (seam-booking)

i want to save user in a transaction and then change his name in another 
transaction, so some changes were made in RegisterAction.java:
   public void register()
  |    {
  |      if ( user.getPassword().equals(verify) )
  |       {
  |          List existing = em.createQuery("select u.username from User u 
where u.username=#{user.username}")
  |             .getResultList();
  |          if (existing.size()==0)
  |          {
  |             persistUser();
  | 
  |             user.setName(user.getName() + "1");
  |             persistUserWithException();
  | 
  |             facesMessages.add("Successfully registered as 
#{user.username}");
  |             registered = true;
  |          }
  |          else
  |          {
  |             facesMessages.addToControl("username", "Username 
#{user.username} already exists");
  |          }
  |       }
  |       else 
  |       {
  |          facesMessages.addToControl("verify", "Re-enter your password");
  |          verify=null;
  |       }
  |    }
  | 
  |     @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
  |     private void persistUser() {
  |         em.persist(user);
  |     }
  | 
  |     @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
  |     private void persistUserWithException() {
  |         em.persist(user);
  |         throw new RuntimeException();
  |     }

this expects that user with original name will be persisted, but change of his 
name won't apply.

but this doesn't work. both operations will be rollbacked because they are in 
the same transaction.

what's wrong? please help me!

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

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4215051
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to