2 Replies Latest reply on Jul 30, 2002 7:42 AM by dxbcto

    How do u do this? Please help.

    dxbcto Newbie

      Hello,

      I am writing a stateless session bean that accesses the DB directly via JDBC. I am using JBoss 2.4.4 on Win2K.

      To make things simple, I have two tables in the DB. TableA has a foreign key into tableB (one -> many relationship). Now I do have a method (one transaction) that does this:

      1. Get an Id from an Oracle sequence for table A.
      2. Use the generated id as a PK and insert a new record in tableA.
      3. Now I would like to insert a record into tableB with a foreign key pointing to the newly-inserted record in tableA.

      The above does not work unless I manually commit the first insertion. But I do not want to do this manually as the transaction might roll back!

      Sorry if I am being too naive...thanks for your help.

      Regards,
      dxbcto