I have a remote method X defined in a stateless session bean as being
TX_REQUIRES_NEW. In the implementation class for method X I call three
non-remote private methods A, B & C. Methods A and C create CMP Entity
beans using their respective create() methods, but method B creates
database records using hard-coded SQL like this:

public void B(int compNum, long oid) throws RemoteException {
        Connection con = null;
        try {
            con = ds.getConnection();

            Statement stmt = con.createStatement();
            stmt.executeUpdate(("INSERT INTO companyMap (compNum, oid) "
+
                    "VALUES (" + compNum + "," + oid + ")"));
            stmt.close();
        } catch (Exception e) {
            throw new RemoteException(e.toString());
        } finally {
            if (con != null) {
                try {
                    con.close();
                } catch (Exception e) {
                }
            }
        }
    }


Trouble is, if there is a problem in with any of the three methods, I
catch the appropriate exception in method X and throw an EJBException
which causes a rollback - but it only rolls back data created in methods
A & C (CMP entity bean records) and not data written to the database in
method B. I want the INSERT statement above to be included in the
transaction started when method X is called.

Any suggestions?

Rob.

==========================================================================To 
unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to