| Summary: | Incorrect primary key for @OrderColumn | ||
|---|---|---|---|
| Product: | z_Archived | Reporter: | Harald Wellmann <hwellmann.de> |
| Component: | Eclipselink | Assignee: | 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: | |||
Setting target and priority. See the following page for details of the meanings of these fields: http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink |
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