Yes, J2EE doesn't support nested transactions.  However, a similar effect can be achieved through the suspension of existing transactions.  As far as I can tell, what's supposed to happen is Transaction 1 gets suspended while Transaction 2 starts, and commits or rollsback.  Then Transaction 1 resumes and commits or rollsback.  Because Transaction 2 will generally throw an exception when it rollsback, Transaction 1 will also generally rollback, which results in an approximation of a nested transaction.  However, this is never explicitly stated in the spec, so it would behoove you to make sure to rollback transactions yourself in your code when you must be SURE they get rolled back.

Since you (Aziz) defined the SQL Delete statement, it doesn't necessarity have to be rolled back if some other transaction rolled back.  I say "doesn't necessarily" because it  really depends on the order and way in which you are doing things.  However, you might want to try adding the following code to your catch clause in the HelloBean or HashCodeBean class.

<code>
sessionContext.setRollbackOnly();
// sessionContext is the SessionContext object that is passed to the Bean in setSessionContext and stored as a member variable as per the EJB 1.1 spec
</code>

Hope this helps.

Anyway, transactions in Orion are still sketchy at best...

-Dan

"Juan Lorandi (Chile)" wrote:

I think it defaults to NotSupported; also have in mind that J2EE only allows
flat transactions,
so, if you a a secuence

Required ---> Requires New
T1                      T2
it will perform 2 transactions, not connected between each other, that is,
if T2 fails, T1 doesn't fail autoamtically.

-----Original Message-----
From: Aziz Sharif [mailto:[EMAIL PROTECTED]]
Sent: Viernes, 03 de Noviembre de 2000 18:11
To: Orion-Interest
Subject: Transaction propagation question

I have a question regarding transaction propagation. I took the orion
primer example and modified it so that the servlet calls Hello and then
the Hello Bean calls A HashCoder bean. Both Hello and HashCoder beans
are stateless session beans and perform SQL. The Hello does a delete
and the HashCoder an incorrect select (causing a SQLException). I was
expection these two operations to happen in the same transaction, so
that the SQLException would cause the delete to automatically rollback
since for both these beans I specified Container managed transaction.
But it did actually delete the row. So it seems they two methods were
running in different transactions.

The only thing I did not do is to specify the tranaction attribute to
the bean's methods to be Required or anything else. I don't know what
it defaults to in orion.

I am using DB2 v. 6.1 as the Database, the in both beans I acquire the
connection through JNDI DataSource. I configured the data-sources.xml
for DB2 as follows:
        <data-source
                class="com.evermind.sql.DriverManagerDataSource"
                name="Db2"
                location="jdbc/Db2CoreDS"
                xa-location="jdbc/xa/Db2XADS"
                ejb-location="jdbc/Db2DS"
                connection-driver="COM.ibm.db2.jdbc.app.DB2Driver"
                username="db2admin"
                password="db2admin"
                url="JDBC:DB2:EB2"
                inactivity-timeout="30"
        />

I am attaching the zip file containing the modified orion primer
example, that can be built simply by tying ant.

I would like to know how to get something like this where multiple
session beans participate in a single transaction such that if any one
throws an SQLException the transaction is rolled back by the container.

Thanks in advance.

Aziz Sharif

__________________________________________________
Do You Yahoo!?
>From homework help to love advice, Yahoo! Experts has your answer.
http://experts.yahoo.com/

-- 
Daniel G. Koulomzin
Digital Media On Demand
244 Brighton Ave. 3rd Floor
Allston MA 02134
 


Reply via email to