• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

afterCompletion Problem

 
Li Xin
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anyone one know if my SFSB implements SessionSynchronization, can I update the database when afterCompletion is invoked?
Thanks.
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As suggested by Figure 8 (Section 7.7.4) in the EJB 2.0 Specification, DB updates should be performed in the beforeCompletion method.
May I ask why do you need to do that in the afterCompletion method?
 
Viktor Sadovnikov
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
afterComplition runs without transactional context. So, I guess, container will be complaining about using data source. And what will commit the changes you do?
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my opinion,
beforeCompletion() method is lastest method that can be change commit or rollback transaction.
afterCompletion(boolean flag) method is not run in transaction (non-TX) so in this method cannot commit or rollback.
//if flag == true then commit
//if flag == false then rollback
please see detail in <b>life cycle of statefull session in EJB 2.0</b>
 
Victor Lar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should be able to update the database in afterCompletion(). You don't need transactions to write to the database.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic