Reputation: 2894
I'm having hard times finding out by looking at the documentations
what shuould happen when I throw a not handled unchecked exception
just after an EJB method has returned.
@Path("helloworld")
public class HelloWorld
{
@EJB
MyEJB myEJB;
@GET
@Produces("text/html")
public String doSomething()
{
myEJB.doSomethingMore();
throw new RuntimeException("Oops");
}
}
Does the EJB commits its DB transaction in such a case or does it rollback ?
Upvotes: 0
Views: 139
Reputation: 36103
HelloWorld is not an EJB so the transaction boundry is around myEJB.doSomethingMore().
if you throw a RuntimeException in HelloWorld the transaction is already commited.
If you want to have the transaciton boundry in HelloWorld simply add @Stateless to your HelloWorld class.
Upvotes: 2