Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 320233

Summary: Lazy fetched ManyToOne field of an embedded object of a newly persisted entity will be set to null on commit
Product: z_Archived Reporter: Igor Mukhin <iimuhin>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P2 CC: iimuhin, tom.ware
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
JUnit Test that fails none

Description Igor Mukhin CLA 2010-07-19 05:21:35 EDT
Build Identifier: 20100617-1415

The detailed information is posted to
http://www.eclipse.org/forums/index.php?t=msg&goto=547642
PLEASE READ THIS POST (it has screenshots)

Reproducible: Always

Steps to Reproduce:
I have an entity Entity1 with a field Embedded1 embedded1.
The class Embedded1 has a field:
@ManyToOne(fetch=FetchType.LAZY) private Person person;

To reproduce the problem:
- create new Entity1 instance with embedded1 and person set
- em.persist(entity1);
- em.commit();
- try read em.find(Entity1.class, id).getEmbedded1().getPerson() will always return null
Comment 1 Igor Mukhin CLA 2010-07-23 14:52:26 EDT
Created attachment 175094 [details]
JUnit Test that fails

This is a small Maven project than demonstrates the bug.

It contains of 
- two @entity classes and one @embeddable, 
- persistence.xml, 
- pom.xml (does static weaving after compiling)
- JUnit test that fails

To run:
- unpack the zip
- run "mvn test"
- Test will fail on second Assert.assertNotNull
Comment 2 Igor Mukhin CLA 2010-07-23 14:55:59 EDT
Important point: weaving required to reproduce
Comment 3 Igor Mukhin CLA 2010-07-23 15:00:59 EDT
pom.xml references EclipseLink 2.2.0-M1, but the same is with 2.1.0
Comment 4 Tom Ware CLA 2010-08-09 13:56:01 EDT
Setting target and priority.  See the following page for details of the meanings of these fields:

http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines
Comment 5 Igor Mukhin CLA 2011-07-22 04:19:55 EDT
It looks like it was fixed in 2.3.0
Comment 6 Tom Ware CLA 2011-07-22 08:19:49 EDT
Closing because of above comment.
Comment 7 Eclipse Webmaster CLA 2022-06-09 10:34:40 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink