Results 1 to 5 of 5

Thread: Why we need "transient EntityManager"?

  1. #1
    Join Date
    Jul 2010
    Location
    HK
    Posts
    12

    Default 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,
    Regards,
    JK

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    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.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Jul 2010
    Location
    HK
    Posts
    12

    Wink

    Marten,

    Thank you for the explanation.
    Regards,
    JK

  4. #4
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    668

    Post

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

  5. #5
    Join Date
    Jul 2010
    Location
    HK
    Posts
    12

    Default

    Andrew,

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •