This question is about ordering inside a composed index, which is a more specific problem than ordering columns inside a table.
I have a simple class with a composed id:
@Embeddable
class PrimaryKeyClass {
private int a;
private int b;
}
@Entity
class SimpleClassWithComposedId {
@EmbeddedId
PrimaryKeyClass id;
}
It seems like hibernate is generating the primary key with the fields ordered by lexicographical order, at least it was what happened in my tests cases. But i would like to know if there is a way to specify the order of the fields in the primary key, because this is very important since we can heavily optmize queries that use a prefix of the composed index ( i have read this in the postgres docs )