Bug 407787 - merge() nullifies @Transient fields in @MappedSuperclass
Summary: merge() nullifies @Transient fields in @MappedSuperclass
Status: CLOSED INVALID
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 blocker (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords: api, core
Depends on:
Blocks:
 
Reported: 2013-05-11 04:04 EDT by Hajo Lemcke CLA
Modified: 2022-06-09 10:23 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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