This content has been marked as final.
Show 4 replies
-
1. Re: rollback
bmhardy Jan 6, 2005 2:39 PM (in response to kabirkhan)In ejb2.1 there was a setSessionContext method. The Container set the context. In any method one could use the context (ctx) to say ctx.setRollbackOnly. How could you do something similar using the ejb3.0 preview? Also in ejb2.1 when a method threw and EJBException a rollback occured automatically I believe. What would be the analogous thing to do when using ejb3.0 preview?
-
2. Re: rollback
kabirkhan Jan 7, 2005 6:10 AM (in response to kabirkhan)In EJB3, you can make sure that the contaner injects the sessioncontext into your sessionbean, by either annotating the setter:
@Inject public void setSessionContext(SessionContext ctx) { this.ctx = ctx; }
or the member variable directly:@Inject SessionContext ctx;
-
3. Re: rollback
bmhardy Aug 29, 2005 4:25 AM (in response to kabirkhan)This doesn't work in the latest ejb 3.0 that comes with as 4.0.3RC2.
What should we use now?
Thanks -
4. Re: rollback
bmhardy Aug 29, 2005 4:40 AM (in response to kabirkhan)I think it goes like this:
private @Injected EntityTransaction tx;
try {
...
} catch (Exception ex)
{
tx.rollback();
}