I am an ejb beginner , i have few doubts regarding transactions and bean method
1) What difference does it make between executing a bean method within an already exisitng transaction and within a new transaction by suspending already running client's transaction.
What difference did you see when you tried it out yourself? Basically
>executing a bean method within an already exisitng transaction
This would be a bean whose transaction attribute may be supports or required. You throw a SystemException or call the setRollBackOnly and the original transaction is rolled back.
>transaction and within a new transaction by suspending already running client's transaction.
This would be a bean whose transaction attribute is 'RequiresNew'. A rollback of this transaction may or may not rollback the suspended transaction based on whether your app server returned a new Connection object for use in your inner transaction. The ejb spec says no nested transaction support - so it's really upto your app server.
The difference between mandatory and required is that the container would throw an exception in the former case if the ejb is invoked without a transaction context. In the later case, it would instead start a new transaction. In the context of the question, you can use either one interchangeably to illustrate the example.
For the second question, AFAIK, there is nothing in the ejb spec that prohibits the container to provide a nested transaction. While it is certainly not supported in the specs, a container if it choses to may return different connection objects for the inner transaction (than the one which is suspended) and hence rollback on the inner would not affect the former. It is a theorotical possibility and it would very much depend on the container implementation.