Announcement Announcement Module
Collapse
No announcement yet.
Why we need "transient EntityManager"? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Why we need "transient EntityManager"?

    Hi,

    Newbie & need help, after search the forum & web, I still don't know why need to put the keyword "transient" before EntityManager.
    Can anyone please explain or show me the place to look for the answer, thanks?

    Code:
        @PersistenceContext
        transient EntityManager Timer.entityManager;
    Regards,

  • #2
    THe objects can get serialized in the httpsession (when used as formobjects for instance) and you really don't want to serialize your entitymanager... Hence the transient... It will be reinjected after deserialization of the objects.

    Comment


    • #3
      Marten,

      Thank you for the explanation.

      Comment


      • #4
        The "transient" keyword also tells JPA to ignore this field when persisting the entity.

        Comment


        • #5
          Andrew,

          I see the reason now, thank you for the explanation.

          Comment

          Working...
          X