| Summary: | FetchType.LAZY fails on @OneToOne within @Embeddable, gives null when accessed | ||
|---|---|---|---|
| Product: | z_Archived | Reporter: | darren |
| Component: | Eclipselink | Assignee: | Project Inbox <eclipselink.orm-inbox> |
| Status: | NEW --- | QA Contact: | |
| Severity: | normal | ||
| Priority: | P2 | CC: | tom.ware |
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | Macintosh | ||
| OS: | Mac OS X - Carbon (unsup.) | ||
| Whiteboard: | |||
Wrongly reported as for version 2.0.3, the correct version is Eclipse Persistence Services - 2.2.0.v20110202-r8913 I am wondering if this is somehow related to how we weave. If so, changing your access type from PROPERTY to FIELD may provide a workaround. Setting target and priority. See the following page for the meanings of these fields: http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines Community: Please vote for this bug if it is important to you. Votes are one of the main criteria we use to determine which bugs to fix next. The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink |
I have an @Embeddable with a @OneToOne relationship: @Embeddable public class GreenStar_ implements Serializable, IGreenStar { private GreenStarOfficeProject officeProject; @OneToOne(fetch= FetchType.LAZY) public GreenStarOfficeProject getOfficeProject() { return officeProject; } Which is used as: @Entity public class GreenStarActivity extends Activity implements IGreenStarElement { private GreenStar_ greenStar; @Embedded public GreenStar_ getGreenStar() { return greenStar; } public GreenStarActivity(Element owner, GreenStarOfficeProject officeProject, String name) { super(owner, officeProject, name); greenStar = new GreenStar_(officeProject); init(); } When getOfficeProject() is accessed in the following transient method in a GreenStarActivity it returns as null (although it was clearly already set): @Transient @Override public boolean isPassed() { String $i = "isPassed"; boolean test = true; resetFailures(); if (getGreenStar()==null) { log_error($i,"getGreenStar()==null"); } else if (getGreenStar().getOfficeProject()==null) { log_error($i,"getGreenStar().getOfficeProject()==null"); } BooleanValue redevelopment = getGreenStar().getOfficeProject().getV893_refurbishment_redevelopment(); I get a NullPointerException on trying to access a getter within the null OfficeProject object above. (I can tell it is null already from the verbose logging, and the GreenStar_ object is clearly not null.) However this works fine when the default FetchType.EAGER is used, it only fails for LAZY. And it only occurs on the relationship within the @Embeddable.