Hi Pooja,

As I understood, u are creating a employee database, which contains three
tables, if u are adding one emploee all his/her complete info. should be
enetered into all three tables, inbetween any problem comes entire
transaction has to be rolled back, is it  yes?


One Q? is it CMT supports the transactions in the helper classes?
Is it not  u design is so complex?

can i tell u a simple design for the same thing.

Wrap three CMB's in a session bean and put all three create stmt in
UserTransaction scope, problem will be solved.

Reply to this mail with u comments on my design, whether it solves or not?

C U Pooja
Reddy





Pooja Keswani <[EMAIL PROTECTED]> on 19/01/2001 01:28:46 PM

Please respond to A mailing list for Enterprise JavaBeans development
      <[EMAIL PROTECTED]>

To:   [EMAIL PROTECTED]
cc:    (bcc: ebreddy/Cds)

Subject:  Re: Container Managed Transactions in Entity Beans




Hi Reddy,
 I would like to give u more information about the problem so that it will
be easier for u to understand it exactly. i m using entity bean  which has
container managed transcation. This ejb has one helper class(DAO) for
database transactions . ejb calls DAO's create method in its ejbcreate
method. now DAO's create method calls one more method named
insertIndividual() which actually updates the D/B ie it executes 3 insert
queries. Now if SQL exception occures in this method, it throws it to
create of DAO and then to ejbcreate of ejb which will throw the
EJBexception  causing rollback . but it is not doing this way. Actually it
says transaction rolled back. but doesn't undo changes in D/B.
what must be happening?
I will appreciate ur reply.
thanks




On Fri, 19 January 2001, E Bakka Reddy wrote:

>
> Hi Pooja,
>
> I understood u problem, no need of doing anything like catching
> SQLException.
>
> What ever i gave in my last mail it works fine.
>
>
> <%@ page import="javax.transaction.*" %>
>
> UserTransaction u = (UserTransaction) ctx.lookup(
> "javax.transaction.UserTransaction");
>   u.begin();
>   deposit=depositHome.create(accountId,balance);
>   System.out.println("Record Created in deposit");
>   accountId="5";
>   withdraw=withdrawHome.create(accountId,balance);
>   System.out.println("Record Created in withdraw");
>   u.commit();
>
> in the above code i am inserting two records into a table from two beans,
> if second bean fails to create, the entire transaction will be rolled
back.
>
>
>
>  otherewise u can use executeBatch
>
> And executebatch.
>
> Statement smt = con.createStatement();
> stmt.addBatch("INSERT INTO COFFEES" +
>               "VALUES('Amaretto', 49, 9.99, 0, 0)");
> stmt.addBatch("INSERT INTO COFFEES" +
>               "VALUES('Hazelnut', 49, 9.99, 0, 0)");
> stmt.addBatch("INSERT INTO COFFEES" +
>               "VALUES('Amaretto_decaf', 49, 10.99, 0, 0)");
> stmt.addBatch("INSERT INTO COFFEES" +
>               "VALUES('Hazelnut_decaf', 49, 10.99, 0, 0)");
>
> stmt.executeBatch(); I hope here also any one of insert stmt fails the
> transaction will rolled back.
>
>
> Edla B. Reddy
>
>
===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff EJB-INTEREST".  For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".


Chequemail.com - a free web based e-mail service that also pays!!!
http://www.chequemail.com

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to