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

Bug 325053

Summary: Incorrect primary key for @OrderColumn
Product: z_Archived Reporter: Harald Wellmann <hwellmann.de>
Component: EclipselinkAssignee: Project Inbox <eclipselink.orm-inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3 CC: tom.ware
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Harald Wellmann CLA 2010-09-12 12:18:31 EDT
Build Identifier: Eclipselink 2.1.1.v20100817-r8050

Given a many-to-many association with an order column, Eclipselink generates an incorrect primary key for the join table. The key should contain the source ID and the order column. The generated key contains the source ID and the target ID. By source and target, I mean the two ends of the association.


Example:

@Entity
@Table(name = "ways")
public class OsmWay
{
    @Id
    private long id;
    
    @ManyToMany(cascade = CascadeType.ALL)
    @OrderColumn(name = "sequence_id")
    @JoinTable(name = "way_nodes", 
               joinColumns = @JoinColumn(name = "id"), 
               inverseJoinColumns = @JoinColumn(name = "node_id"))
    private List<OsmNode> nodes = new ArrayList<OsmNode>();
}    


This entity is represented by two tables:

CREATE TABLE ways
(
  id bigint NOT NULL
);

CREATE TABLE way_nodes
(
  id bigint NOT NULL,
  node_id bigint NOT NULL,
  sequence_id integer,
);

Eclipselink generates a PRIMARY KEY (id, node_id) for way_nodes. This should be (id, sequence_id).



Reproducible: Always
Comment 1 Tom Ware CLA 2010-09-20 08:28:43 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 2 Eclipse Webmaster CLA 2022-06-09 10:02:26 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink