1 Reply Latest reply on Oct 23, 2009 11:24 PM by Arbi Sookazian

    Seam wouldn't persist data and stuck with the insert statement.

    Jenny Jasti Newbie

      I have problem with persisting the data to database, Is this an issue with seam. I am using the following code to store the data into the database, it works fine for once or twice but fails every time, not sure why it works sometimes and fails remaining times.


      It tries to insert the data into the database and stuck with the insert satement, in other words it is not moving, after a lot of time i get the following Exception


       for(GwpsProofNotification ccNot : gwpsProofWorkflow.getGwpsProofNotifications()) {
                         if(ccNot.getGwpsEmailType().getEmailTypeDescription()!= null && ccNot.getGwpsEmailType().getEmailTypeDescription().equals("Task Notification")) {
                                 for (String ccUserSelected : ccListSelected) {    
                                         ccUser = entityManager.find(GwpsUser.class, Long.valueOf(ccUserSelected));
                                         for(GwpsEmailRecipient notRecipients : ccNot.getGwpsEmailLog().getGwpsEmailRecipients()) {
                                               if(ccUser != null && notRecipients.getId().getRecipientType().equals("CC") && ccUser.getUserId() == notRecipients.getGwpsUser().getUserId()) {
                                                      flag = 1;
                                               }
                                               log.info(notRecipients.getGwpsUser().getUserId());
                                              if(ccUser != null && notRecipients.getId().getRecipientType().equals("CC") && !ccListSelected.contains(notRecipients.getGwpsUser().getUserId())) {
                                                       //delete the user record from recipients table
                                                       notRecipients = entityManager.merge(notRecipients);
                                                      entityManager.remove(notRecipients);
                                               }
                                         }                               
                                 }
                                 emailLog = ccNot.getGwpsEmailLog();             
                                 if( flag == 0) {
                                         GwpsEmailRecipient ccRecp = new GwpsEmailRecipient();
                                         ccRecp.setGwpsEmailLog(emailLog);
                                         ccRecp.setGwpsUser(ccUser);
                                         ccRecp.setId(new GwpsEmailRecipientId(emailLog.getEmailLogId(), "CC", ccUser.getUserId()));
                                         entityManager.persist(ccRecp);
                                 }
                                 flag=0;                         
                         } else if(ccNot.getGwpsEmailType().getEmailTypeDescription()!= null && ccNot.getGwpsEmailType().getEmailTypeDescription().equals("Task Reminder")) {
                                 for (String ccUserSelected : ccReminderListSelected) {    
                                         ccUser = entityManager.find(GwpsUser.class, Long.valueOf(ccUserSelected));
                                         for(GwpsEmailRecipient notRecipients : ccNot.getGwpsEmailLog().getGwpsEmailRecipients()) {
                                               if(ccUser != null && notRecipients.getId().getRecipientType().equals("CC") && ccUser.getUserId() == notRecipients.getGwpsUser().getUserId()) {
                                                      flag = 1;  
                                               }
                                              log.info(notRecipients.getGwpsUser().getUserId());
                                              if(ccUser != null && notRecipients.getId().getRecipientType().equals("CC") && !ccReminderListSelected.contains(notRecipients.getGwpsUser().getUserId())) {
                                                       //delete the user record from recipients table
                                                       notRecipients = entityManager.merge(notRecipients);
                                                      entityManager.remove(notRecipients);
                                               }
                                         }                               
                                 }
                                 emailLog = ccNot.getGwpsEmailLog();             
                                 if( flag == 0) {
                                         GwpsEmailRecipient ccRecp = new GwpsEmailRecipient();
                                         ccRecp.setGwpsEmailLog(emailLog);
                                         ccRecp.setGwpsUser(ccUser);
                                         ccRecp.setId(new GwpsEmailRecipientId(emailLog.getEmailLogId(), "CC", ccUser.getUserId()));
                                         entityManager.persist(ccRecp);
                                 }
                                 flag=0;                        
                         } else if(ccNot.getGwpsEmailType().getEmailTypeDescription()!= null && ccNot.getGwpsEmailType().getEmailTypeDescription().equals("Task Overdue")) {
                                 for (String ccUserSelected : ccOverdueListSelected) {    
                                         ccUser = entityManager.find(GwpsUser.class, Long.valueOf(ccUserSelected));
                                         for(GwpsEmailRecipient notRecipients : ccNot.getGwpsEmailLog().getGwpsEmailRecipients()) {
                                               if(ccUser != null && notRecipients.getId().getRecipientType().equals("CC") && ccUser.getUserId() == notRecipients.getGwpsUser().getUserId()) {
                                                      flag = 1;                                               
                                               }
                                              log.info(notRecipients.getGwpsUser().getUserId());
                                              if(ccUser != null && notRecipients.getId().getRecipientType().equals("CC") && !ccOverdueListSelected.contains(notRecipients.getGwpsUser().getUserId())) {
                                                       //delete the user record from recipients table
                                                       notRecipients = entityManager.merge(notRecipients);
                                                      entityManager.remove(notRecipients);
                                               }
                                         }                               
                                 }
                                 emailLog = ccNot.getGwpsEmailLog();             
                                 if( flag == 0) {
                                         GwpsEmailRecipient ccRecp = new GwpsEmailRecipient();
                                         ccRecp.setGwpsEmailLog(emailLog);
                                         ccRecp.setGwpsUser(ccUser);
                                         ccRecp.setId(new GwpsEmailRecipientId(emailLog.getEmailLogId(), "CC", ccUser.getUserId()));
                                         entityManager.persist(ccRecp);
                                 }
                                 flag=0;                       
                         }
                         emailLog = entityManager.merge(emailLog);
                         entityManager.persist(emailLog);
                 }      
      





      2009-10-23 13:59:47,283 DEBUG [com.arjuna.ats.jta.logging.loggerI18N] [com.arjuna.ats.internal.jta.recovery.info.secondpass] Local XARecoveryModule - second
       pass
      2009-10-23 13:59:57,678 WARN  [com.arjuna.ats.arjuna.logging.arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.BasicAction_58] - Abort of action id 7f000001
      :8be4:4ae1e954:77 invoked while multiple threads active within it.
      
      



      and would never move.


      Please help me out.


      Thanks.