Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 314941 - multiple joinColumns without referenced column names defined, no error
Summary: multiple joinColumns without referenced column names defined, no error
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-28 14:44 EDT by Karen Butzke CLA
Modified: 2022-06-09 10:24 EDT (History)
2 users (show)

See Also:


Attachments
Proposed changes (13.48 KB, patch)
2010-05-31 09:49 EDT, Guy Pelletier 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 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