Commiting of transaction


EJB programming & troubleshooting: Commiting of transaction

  1. Commiting of transaction (2 messages)

    I have two stateless session beans A and B , both of them having Container Managed transaction.
    A client initiates one method of A which is calling a method of B in a loop some 100 times, which is doing some insertion of record in Database. This operation takes a lot of time. So if another client tries to view the records in between that operation , he is not able to view the already inserted records because the records will not be committed(after returning from B) until the call from A returns.

    How can i view the already created records from another client? how can i get the data be committed after each successful insertion of record? Should i make bean A Bean managed transaction?

    Threaded Messages (2)

  2. Commiting of transaction[ Go to top ]

    I do not think you need to convert the "B" EJB to Bean Managed. (Although, that can work) Change the transactional attribute of the "B" EJB to "requiresNew". This will start a new transaction, everytime B is called.

    The downside to this approach is that this process will take longer, because you have 100 commits instead of 1 commit.
  3. Or change the isolation level[ Go to top ]

    If dirty reads are not an issue in your application, then instead of setting the transactional attribute on EJB B's method to RequiresNew, simply change the Transaction Isolation level to READ_UNCOMMITED, provided your database supports this isolation level, I know Oracle does not support it.