3 Replies Latest reply on Oct 31, 2011 11:41 AM by alesj

    JEE unusable?

    ben_utzer

      All CDI managed beans that belong to a scope that is ultimately bound to the HttpSession need to be serializable. Which means all attributes need to be serializable. EntityManager is not though this seems to be considered a bug (here and here (I don't know why it's closed.)).


      This means if you want to adhere to the spec you cannot use JPA from CDI scopes like Session or Conversation.


      Seems JEE is close to unusable or what?

        • 1. Re: JEE unusable?
          alesj

          Why would you wanna serialize EntityManager?


          Simply mark it as transient, and get it re-injected when you need it.

          • 2. Re: JEE unusable?
            ben_utzer

            All information that existed in the PersistenceContext would be lost. I think I can live with that as long as no extended PersistenceContext is used. I wonder why I seldom see examples where the injected EntityManager is marked transient...


            Thanks for your suggestion!

            • 3. Re: JEE unusable?
              alesj

              Imo, extended PC should work, even if you mark it transient, as it should be handled by the container.


              (but I'm no JPA / EJB3 expert ...)