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

    How do u do this? Please help.

    dxbcto

      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

        • 1. Re: How do u do this? Please help.
          davidjencks

          This seems very odd. Are you using the same connection for both inserts? Does your code work OK in a standalone app? Did you get your connection from a datasource deployed from an XADataSourceLoader?

          • 2. Re: How do u do this? Please help.
            dxbcto

            Oops....I found my problem! It is in the deployment descriptor...it should have stated that the transaction type is container instead of bean! I guess I assumed it was container. Thanks for your help.