Guest User

Untitled

a guest
Aug 16th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. Invoke transactional method within the same SFSB
  2. @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
  3. @Stateless
  4. public class MyService {
  5.  
  6. @Resource
  7. SessionContext ctx;
  8.  
  9. public void myMethod() {
  10. // do something...
  11.  
  12. // invoke method from the same class
  13.  
  14. // As expected - this doesn't work as it's a regular local-call,
  15. // it's not aware of EJB nature of this call.
  16. save();
  17.  
  18. // Doesn't work (although it worked with SLSB)
  19. ctx.getBusinessObject(MyService.class).save();
  20. }
  21.  
  22. @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
  23. public void save() {
  24. // do something...
  25. }
  26. }
Add Comment
Please, Sign In to add comment