Skip to Main Content

Integration

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

[JPA] @Transient fields are set to null during merging

173391Jun 29 2007 — edited Jun 29 2007

Hi,

I noticed that when merging an entity into a persistence context, the merged copy resets all @Transient fields to null.

For example:

    EntityManager em = emf.createEntityManager();
    Declaration decl = em.find(Declaration.class, 63L);
    em.clear();
    em.close();

    decl.setStatus(DeclarationStatus.ACCEPTED);  // modify a @Transient field

    em = emf.createEntityManager();
    EntityTransaction tx = em.getTransaction();
    tx.begin();
    Declaration mergedDecl = em.merge(decl);

    System.out.println("decl. status=" + decl.getStatus());
    System.out.println("merged status=" + mergedDecl.getStatus());

    tx.commit();

The output is:

decl. status=ACCEPTED
merged status=null

Could anybody tell me what's the intended behaviour of JPA? Are the @Transient fields supposed to be reset?

I tried with TopLink Essentials v2-b41 and v2-b52.

Best regards,
Bisser

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 27 2007
Added on Jun 29 2007
2 comments
2,312 views