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

    Long transaction

    leonell

      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

        • 1. Re: Long transaction

          By default transaction timeout set to 5 minutes (300 sec).
          It can be changed in JBOSS_HOME/../deploy/jta-service.xml file. Look for 300 line and change value 300 to value which is appropriate for you.