Transaction Handling for combination of EJB and Stored Procedure

Discussions

EJB programming & troubleshooting: Transaction Handling for combination of EJB and Stored Procedure

  1. Hi,

    I need to use the combination of stored procedure and entity beans such that in between the logic which is implemented in the session bean I need to call the stored procedure. This stored procedure makes some entries in the the table. My problem is that the entity beans which I am using are container managed, so if some exception occurs in the method after SP is invoked the rows inserted by procedure is not rolled back. Is there any solution to this?

    thanks in advance
    Manish
  2. Manish:

        Two things are happening here,

        1. CMPs are managed by container and hence you decide what kind of transaction management is done in DD.

        2. You are making a direct db call to start your SP, and hence you will have to manage the transactions. check java.sql.* package. secondly in ur CMPs make dd setting which will force cmp to have already existing transaction.

        This way you will control ur commit and rollback.

    I guess your pl error is comminting all coz db settings are like that.

    ONE MORE IMPORTANT THING, CONFIRM THAT IN YOUR PL THERE IS NOT COMMIT STATEMENT. IF THATZ THERE THEN YOUR TRANSACTION MANAGEMENT IS OF NO USE.

    Regards
    Chetan