users@glassfish.java.net

JPA/Toplink? question related to _at_Transient fields

From: <glassfish_at_javadesktop.org>
Date: Wed, 14 May 2008 11:27:57 PDT

I have a a superclass that is [i]not[/i] an @Entity.

Descending from it I have an @Entity subclass.

The superclass defines a non-transient field called, for whatever it's worth, logicDelegate. It has bound getters and setters for this property.

The subclass overrides the getter and annotates it with the @Transient annotation. This indicates that I don't want the JPA provider to try to persist the contents of the logicDelegate field.

So this means, now, I have a non-transient--but @Transient--property called logicDelegate.

When I ask an EntityManager to merge my subclass in, everything persistence-related works fine. The logic delegate is not shoved at the database in any way. That's good; it makes no sense as a [i]persistent[/i] property of this @Entity.

But the return value of the merge() method gives me back an instance of the subclass whose logicDelegate field is now null.

Maybe I'm not thinking clearly--entirely possible--but why would non-transient (little t, no annotation) fields get erased in this return value? I understand why @Transient properties don't get persisted, obviously, but shouldn't the return value of merge() attempt to preserve non-transient but @Transient state in the objects it works on?

I don't recall seeing mention of this in the specification; I'm going to go consult it.

Thanks for any help,
Laird
[Message sent by forum member 'ljnelson' (ljnelson)]

http://forums.java.net/jive/thread.jspa?messageID=274363