• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

afterCompletion Problem

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Anyone one know if my SFSB implements SessionSynchronization, can I update the database when afterCompletion is invoked?
Thanks.
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic