5 Replies Latest reply on Apr 13, 2010 3:33 AM by Nikolay Elenkov

    How to send an email after the transaction completes?

    Drew Kutchar Newbie
      What's the correct way of doing the following in Seam?

      1- Get object from DB
      2- Modify Object
      3- Call EntityManager.flush() [assume Seam Managed Persistence Context in Long Running Conversation with manual flush]
      4- Send email to the user that the object was modified with the details of the object.

      It might look simple, but there are two issues:
      1- You do not want to send the email if the transaction wasn't able to commit.
      2- If the Object has any lazily initialized fields that weren't fetched before the flush and are used in the email generation, then you might get a LazyInitialzationException with a root cause of Transaction was already committed.

      How are you guys handling this?

      Thanks,

      Drew