I was experimenting with BMT and StatefulBean in EJB 3 using JBoss 6 server along with MySQL as database. The SFSB has two methods. Both the methods are inserting some data in Database. Following is the code for the SFSB:
@Remote(StatefulBMTRemote.class)
@Stateful(name="StatefulBeanBMT")
@Resource(name="jdbc/MySqlDS",
mappedName="java:/MySqlDS", type=javax.sql.DataSource.class)
@TransactionManagement(TransactionManagementType.BEAN)
public class StatefulBMTBean
{
From a standalone java client when I am accessing the SFSB I founded that even if I call cancelAdd(), The rollack is not taking place and data is staying in Database. After Stacktrace enabling I found no exception either.
Keep the transaction open across bean methods is something that can be done through SFSB only and though as the most promising benefit you can never achieve through SLSB. So why is this happening so I am absolutely clueless about.
Please help.
Thanks in advance.
KB
Thanks in advance.
Cheers
KB
-----------------------
SCJP6(95%), OCPJBCD(100%)
Where exactly I should set the autocommit false for MySQL. My guess is I need to set this property at data source level, meaning in the mysql-ds file? Or shall I set this on the Connection after getting it from Datasource?
I am not getting any exception on client as well as at the server end.
Jaroslaw,
What I don't get is why I should bother about commit.
When I am using CMT and doing some operation distributed over two different SLSB with transaction attribute REQUIRED, if I get any exception at the second bean and mark the transaction for rollback the entire operation gets rolled back by the container and even if there is a successful database DML operation in the first bean that will be rolled back too.
For BMT only difference is the application is starting the transaction. So my expectation was that whatever database operation I am doing over different methods of a SFSB, all will be committed only if I commit transaction.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: EJB 3 Stateful BMT SessionBean Open Transaction not behaving properly