5 Replies Latest reply on Sep 10, 2008 5:48 PM by he youlin

    last seam 2.1 SpringTransaction bug?

    he youlin Novice
      1.when i use spring:spring-transaction the compenent using in jsf with @Transactional use Transaction.instance().setRollbackOnly().
      And after Transaction.instance().setRollbackOnly() it cause following EntityManager a org.hibernate.LazyInitializationException.
      
      @SuppressWarnings("unchecked")
          @Transactional
           public void editFibre()    {          
                
              editFibre.setIsReturn(1);
              editFibre.setInvStatus(1);
      
              try{
                       SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
                       transService.dotrans(editFibre.getItem(), entityManager.find(Inventory.class,"yosc-m1"),
                                 editFibre.getSalesLenght(), "fibreturn"+df.format(new Date()), "material-return", editFibre.getFibreNo(), user);
                  }catch(Exception e)
                  {
                       try {
                          Transaction.instance().setRollbackOnly();
                     } catch (IllegalStateException e1) {
                          // TODO Auto-generated catch block
                          e1.printStackTrace();
                     } catch (SecurityException e1) {
                          // TODO Auto-generated catch block
                          e1.printStackTrace();
                     } catch (SystemException e1) {
                          // TODO Auto-generated catch block
                          e1.printStackTrace();
                     }
                     queryFibres();
                     FacesMessages.instance().add( "ssss" );
                     return;
                  }
           
             entityManager.merge(editFibre); 
            queryFibres();
          }
      
      
      2.If this stage use in WebRemote transaction can't rollback.If use Transaction.instance().rollback() will cause "No transaction currently active that Seam started.Seam should only be able to committ or rollback transactions it started.""
      @WebRemote
             @Transactional
             public String productIn(Product bk) throws YoscException{
      
                
                entityManager.merge(bk);
               
               if(bk.getStatus().equals("30"))
               {
                    try {
                          Transaction.instance().setRollbackOnly();
                     } catch (IllegalStateException e) {
                          // TODO Auto-generated catch block
                          e.printStackTrace();
                     } catch (SecurityException e) {
                          // TODO Auto-generated catch block
                          e.printStackTrace();
                     } catch (SystemException e) {
                          // TODO Auto-generated catch block
                          e.printStackTrace();
                     }
                     
                    return("connot 30!");
               }
               return "success!";
             }
      
      
      
      
      It is a bug?