Hi everyone,

I have a problem with transactions.

My aim is to have two sql 'inserts' in one function. The function is
covered by the 'Required' attribute in the xml file. The data source
is used from the 'ejb-location'. If one insert fails , the container
rolls back all the other database inserts in the function. But the
example working in the J2EE implementation is not working in the Orion
one. Do I have to go for a 'resource ref' in the xml file, is it
because of this the transaction fails? Because in all the examples
everyone accesses the data sources using the jdbc/XXXXX which is there
in the data sources.xml directly.

the code is shown below.

<data-source
          class="com.evermind.sql.DriverManagerDataSource"
          name="OracleDS"
          location="jdbc/OracleCoreDS"
          xa-location="jdbc/xa/OracleXADS"
          ejb-location="jdbc/OracleDS"
          connection-driver="oracle.jdbc.driver.OracleDriver"
          username="scott"
          password="tiger"
          url="jdbc:oracle:thin:@192.168.0.5:1521:dcom"
          inactivity-timeout="30"
     />

The code in the bean (Session)

InitialContext ic = new InitialContext();
DataSource ds = (DataSource)ic.lookup("jdbc/OracleCoreDS");
Connection con = ds.getConnection();

I have two updates in one function (setDBItems()). I have put a 'Required' attribute 
for it in the ejb-jar.xml

<container-transaction>
              <description>no description</description>
              <method>
                 <ejb-name>MyCart</ejb-name>
                 <method-name>*</method-name>
              </method>
              <trans-attribute>NotSupported</trans-attribute>
           </container-transaction>
           <container-transaction>
              <method>
                 <ejb-name>MyCart</ejb-name>
                 <method-name>setDBItems</method-name>
                 <method-params>
                    <method-param>java.lang.String</method-param>
                    <method-param>java.lang.String</method-param>
                    <method-param>java.lang.String</method-param>
                    <method-param>java.lang.String</method-param>
                 </method-params>
              </method>
              <trans-attribute>Required</trans-attribute>
      </container-transaction>

The problem here is that the first update occurs but when the second fails the first 
does not rollback.
As per my understanding any problem in one of the database transactions in the 
function rolls back al the others
in the same function.

Any clue on this? If someone has some example code on this, could you please send it 
to me?

Thanks in advance
Regards
Aby Philip


Reply via email to