Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 362234 - [EclipseLink] default 1-1 derived id mapping appears as an id mapping, causes invalid validation
Summary: [EclipseLink] default 1-1 derived id mapping appears as an id mapping, causes...
Status: VERIFIED FIXED
Alias: None
Product: Dali JPA Tools
Classification: WebTools
Component: JPA (show other bugs)
Version: 3.0.1   Edit
Hardware: PC Windows Mobile 5.0
: P2 major (vote)
Target Milestone: 3.3 M2   Edit
Assignee: Paul Fullbright CLA
QA Contact:
URL:
Whiteboard: fix_ready
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-27 15:04 EDT by Karen Butzke CLA
Modified: 2013-02-20 12:37 EST (History)
2 users (show)

See Also:


Attachments
example project (64.23 KB, application/x-zip-compressed)
2011-11-02 09:53 EDT, Karen Butzke CLA
no flags Details
patch (4.66 KB, patch)
2012-04-27 14:38 EDT, Paul Fullbright CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Karen Butzke CLA 2011-10-27 15:04:03 EDT
we have incorrect validation for an EclipseLink default 1-1 derived id mapping. Import the attached project and notice that the Administrator.emp mapping is an id mapping instead of a 1-1 mapping in the JPA structure view. If you generate tables for this project you will get 3 incorrect validation errors. Remove the Id annotation and add it back and the problem is resolved. But if you rebuild the project or restart eclipse the problem comes back.
Comment 1 Karen Butzke CLA 2011-11-02 09:53:22 EDT
Created attachment 206330 [details]
example project

@Entity
public class Administrator {
    @Id
    protected Employee emp;
}

@Entity
public class Employee  {
    @Id
    protected Integer id;
}
Comment 2 Paul Fullbright CLA 2011-11-14 16:04:10 EST
The problem is this:

- The determination of whether a mapping is specified "id" depends on the default mapping (and whether it is default 1-1).
- The determination of whether a mapping is default 1-1 depends on the model being interconnected (a target entity must be resolveable.)
- When we initialize the attribute, we only initialize the specified mapping information.
- When we update, we only update the default mapping information if it is not a specified mapping, which it is from the initialized.  We do not re-evaluate the specified mapping based on the new (potentially) default mapping information, and we do not re-evaluate the default mapping, because the mapping is already determined to be specified.

In other words, it's fairly complicated.

Deferring to 3.2 for these reasons:
- see above (it's complicated)
- it's not a regression (this exists in previous release)
- this only exists for EclipseLink 2.0 + platforms, and then only in this particular case.
- there is a very good workaround: simply add the @OneToOne annotation.
Comment 3 Paul Fullbright CLA 2012-04-27 14:38:27 EDT
Created attachment 214729 [details]
patch

The code actually simplifies a bit when you're checking both the default and specified mapping in the same method.  All tests pass (including added test case) and Karen can't break it.
Comment 4 Neil Hauge CLA 2012-05-08 17:03:00 EDT
Given possible risk associate with this fix, and given that it has not been reported in the field, I think it is best if we defer this to 3.3 M1.
Comment 5 Paul Fullbright CLA 2012-07-12 19:13:39 EDT
committed fix for 3.3 M1.
Comment 6 Jolene Moffitt CLA 2013-02-20 12:37:06 EST
Verified in build I-3.5.0-20130212155715 that when you Import the attached project the mapping show correctly as one-to-one.  To view steps to verify this issue go to http://wiki.eclipse.org/Dali_3.3_M2_Release