Session beans are not transactional like this.  See EJB 1.1 Spec Section
6.4.2. You either need to use an entity bean or else build in the rollback
to previous state logic yourself.

Cheers
Jay Walters

-----Original Message-----
From: Rhodes, Phillip C. [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 31, 2001 6:30 AM
To: JRun-Talk
Subject: cannot get simple session bean transaction to work.


I have a session bean with methods that changes its state.

//cart is session bean
ShoppingCart cart = ...
try {
        transaction.begin();
        System.out.println(cart.getVariable());//returns "b" here before
trying to change state.
        //first method call (successful)
        cart.setVariable("x");
        //second method call (generates error)
        cart.setVariable("y");
      transaction.commit();
} catch (Exception e) {
        transaction.rollback();
}

Now if the call to the second method generates an error, I would like to
bean to be rolled back to it pre-existing state.  I would like to exit the
transaction rollback to where my variable is "b" again.

I have set the ejb.transactionAttribute to all the different possible
values, especially "BeanManaged".
Sometimes it just hangs....
I would definitely appreciate a pointer.  Thanks!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to