1 Reply Latest reply on Oct 6, 2005 10:01 AM by Ramil Israfilov

    Long transaction

    Leos Urban Newbie

      Hello,
      I need import many thousands records from one (non JBOSS) database into our entities. I made session bean method importData() with loop (one big transaction).
      After five minutes I get warning "Transaction timed out".

      Example:

      @PersistenceContext(unitName="manager") EntityManager manager;
      @PersistenceUnit(unitName="manager") EntityManagerFactory factory;
      
      @TransactionAttribute(TransactionAttributeType.REQUIRED)
      public void importData()
      {
       while ( all rows from other database)
       {
       Company c = new Company();
       c.setName( name );
       manager.persist( c);
       }
      }
      


      When I have this loop in client (not in session bean method) and call my SB insert() method then it works fine (many small transactions).
      @TransactionAttribute(TransactionAttributeType.REQUIRED)
      public void insert(Company o)
       {
       if (o!=null)
       {
       manager.persist( o );
       }
      }
      


      How to solve it?
      Or how to create user managed transaction (begin, commit after 1000 rows) in session bean?

      EJB3 RC1

      Leonell