I use Spring Data JPA and PostgreSQL 10.
Given the classes
@Entity
@Table(name = "test_table")
@IdClass(TestTableId.class)
public class TestTable {
@Id
private int b;
@Id
private int a;
private int c;
// Getters, setters, hashCode() and equals()
}
and
public class TestTableId implements Serializable {
private int b;
private int a;
// Constructors, getters, setters, hashCode() and equals()
}
In the DB the table is created by hibernate via
CREATE TABLE test_table
(
a integer NOT NULL,
b integer NOT NULL,
c integer NOT NULL,
CONSTRAINT test_table_pkey PRIMARY KEY (a, b)
)
I want PRIMARY KEY (a, b)
instead of PRIMARY KEY (b, a)
for performance reasons. How can I achieve this without renaming the columns?