I'm using @OrderColumn in a many-to-many relationship:
@Entity
@Getter
@Setter
@SuperBuilder
@NoArgsConstructor
public abstract class BaseClass{
private UUID id;
...
@ManyToMany
@JoinTable(
name = "joint_table",
joinColumns = {
@JoinColumn(name = "base_id")
},
inverseJoinColumns = {
@JoinColumn(name = "item_id")
}
)
@OrderColumn
@Builder.Default
protected List<Item> items= new ArrayList<>();
...
The order column is being recorded as expected. So persisting is not an issue. However, when i try to read the list with the getter:
myBaseClassInstance.getItems();
I can see the generated SQL is not including an 'ORDER BY' statement.
What am I doing wrong? How ca I enforce the ordering column to be used while retrieving the list?
Thanks in advance