On Jun 22, 2008, at 11:17 AM, Martin Uhlir wrote:

hi,

i'm new to ejb so sorry for my simple question, but i could not find the answer anywhere. i have a web app using openejb. in a client i call a business mothod of an ejb bean and the question is how i can get to know in the client if the business method was commited or rolled back?? i need to know this to be able to decide which page should be returned to the user.

For container managed transactions (the default) you can assume the transaction was committed if no exception was thrown to the client (either by the bean or the container).

If an exception was received by the client it still may be possible that the transaction was still committed. The bean can throw "App Exceptions" which the container will treat as a normal return type will not cause the container to rollback the transaction. The basic policy is throwing a checked exception (i.e. it's declared in your throws clause) from the bean method does not cause the container to rollback the transaction, throwing an unchecked exception (i.e. a RuntimeException or subclass) from the bean method does cause the container to rollback the transaction. A minor note, it is possible to throw unchecked exceptions and have them not rollback the transaction by annotating them with @ApplicationException, though most people don't use that feature.

-David



Reply via email to