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

Bug 314941

Summary: multiple joinColumns without referenced column names defined, no error
Product: z_Archived Reporter: Karen Butzke <karenfbutzke>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: eclipselink.orm-inbox, guy.pelletier
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed changes none

Description Karen Butzke CLA 2010-05-28 14:44:39 EDT
Given the following example, I generated DDL and no exception was given. I am trying to figure out what the default referenced column name for a join column is in this case, or in the case where one of the referenced column names is specified.

@Entity
@IdClass(EntityAIdClass.class)
public class EntityA {
    @Id
    private int id;

    @Id
    private int id2;
  
    @ElementCollection    
    @CollectionTable(name="EmbeddableType" ,  
            joinColumns={
                @JoinColumn(name="id"), 
                @JoinColumn(name="owningEntity")
            }
    )
    @MapKey(name="language") 
    private Map<String, EmbeddableType> embeddableTypes;
}

public class EntityAIdClass {
    private int id;
    private int id2;
}

@Embeddable
public class EmbeddableType {
    @Column(name="data") 
    private String data;

    @Column(name="language", nullable=false)
    private String language;
}
Comment 1 Guy Pelletier CLA 2010-05-28 15:58:43 EDT
When processing the join columns of the element collection we are incorrectly using the embeddable's descriptor to validate the join columns.
Comment 2 Guy Pelletier CLA 2010-05-31 09:49:08 EDT
Created attachment 170526 [details]
Proposed changes

Issue here was that for an element collection containing an Embeddable we would incorrectly pass in the embeddable's descriptor to validate the join columns.

It's also wrong in the sense that we would also incorrectly default the join columns in a composite primary key case. 

A new test has been provided.
Comment 3 Guy Pelletier CLA 2010-05-31 10:15:15 EDT
Changes have been submitted

Reviewed by: Tom Ware

Tests: Expanded test (testCreateDepartment) from AdvancedCompositePKJunitTest. Also tested the negative test manually on my machine and on Karen's machine.
Comment 4 Eclipse Webmaster CLA 2022-06-09 10:24:37 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink