Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 325053 - Incorrect primary key for @OrderColumn
Summary: Incorrect primary key for @OrderColumn
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-12 12:18 EDT by Harald Wellmann CLA
Modified: 2022-06-09 10:02 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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