Bug 407787

Summary: merge() nullifies @Transient fields in @MappedSuperclass
Product: z_Archived Reporter: Hajo Lemcke <hajo>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: CLOSED INVALID QA Contact:
Severity: blocker    
Priority: P3 CC: tom.ware
Version: unspecifiedKeywords: api, core
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Hajo Lemcke CLA 2013-05-11 04:04:20 EDT
@Transient fields in a @MappedSuperclass become null after merge(). They are null already in the @PrePersist method which is a blocker, since I need to use it there to obtain the user id and some other stuff.

Reproducible: Always

Using: @Access(AccessType.PROPERTY)
Comment 1 Hajo Lemcke CLA 2013-05-11 12:42:52 EDT
Additional info:

This bug remains also when "eclipselink.weaving" = "false".

It seems that somewhere within the "merge()" code a new instance of my class gets instantiated and only fields which are not @Transient get copied. This behavior sets all non-@Transient fields to their initial value.

How do I get some information into @PrePersist, @PreUpdate and others which will not go into the database?
Comment 2 Tom Ware CLA 2013-05-24 10:39:05 EDT
By default, we use the mappings to copy objects when we do a merge, hence unmapped objects will be ignored.

The best way to override this behavior is to specify a CloneCopyPolicy on your object that will give you better control of the way the object is copied.

http://www.eclipse.org/eclipselink/documentation/2.4/jpa/extensions/a_clonecopypolicy.htm#CDDJGFHA

Closing as INVALID
Comment 3 Eclipse Webmaster CLA 2022-06-09 10:23:52 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink