5 Replies Latest reply on Jul 30, 2014 11:27 AM by born_free

    transaction propagation and jdbc dao in ejb 2.1

    born_free

      Hello All,

      I have a stateless session bean, in one of the methods I am using jdbc dao to get some data from db. This dao does select query. Session bean starts transaction and updates data, within same transaction I want to retrieve that data using jdbc dao. Since the data is not yet committed dao does not returns correct values. Jdbc dao does not have any transaction related logic it has just one select query. jdbc dao get connection from jndi. Any idea why the transaction started by session bean cannot be propagated to jdbc?

      Is there any other way to get the updated data in same transaction using dao?

       

      Any help is highly appreciated.

        • 1. Re: transaction propagation and jdbc dao in ejb 2.1
          wdfink

          Do you use the same connection pool? also it is possible that the pool did not return the same connection for different request in the same transaction.

          It looks like a configuration issue, but you might share a bit more information if you need more help.

          • 2. Re: transaction propagation and jdbc dao in ejb 2.1
            born_free

            Thanks Wolf-Dieter Fink for response.

            You might be correct I do think that it is getting new connection when querying within transaction.

             

            My jboscmp-jdbc.xml has following

             

            <jbosscmp-jdbc>

               <defaults>

                 <datasource>java:/OracleDS</datasource>

                 <datasource-mapping>Oracle9i</datasource-mapping>

                 <create-table>false</create-table>

                 <remove-table>false</remove-table>

               </defaults>

            ...

             

            My Oracle-ds.xml file has following

            datasources>

                <xa-datasource>

                    <jndi-name>OracleDS</jndi-name>

            ....

             

            And the dao references OracleDS using JNDI. We are using jboss 4.2.2.

             

            Thanks

            • 3. Re: transaction propagation and jdbc dao in ejb 2.1
              born_free

              Is there any test which I can do to find out if the connection object returned is different than what is used by session bean?

              • 4. Re: transaction propagation and jdbc dao in ejb 2.1
                wdfink

                Not sure whether this was possible in AS4.2.

                Maybe you do a short test and set the root-logger to TRACE and see if you have details from the connection-pool

                • 5. Re: transaction propagation and jdbc dao in ejb 2.1
                  born_free

                  I modified jbossjta-properties.xml and jboss-log4j configuration to enable jta logging and it dump too much logs. Application is taking long time to deploy and access is very slow. I review the logs to see if I can understand anything...is there any way we can check only see transaction related or connection pool related logs?