I\'m trying to use the @OrderColumn
annotation with Hibernate 3.5
@OneToMany(mappedBy = \"parent\",fetch=FetchType.EAGER, cascade=CascadeType.AL
Do something like this:
@Entity
class Parent {
@OneToMany
@OrderColumn(name = "pos")
List children;
}
@Entity
class Child {
@ManyToOne
Parent parent;
@Column(name = "pos")
Integer index;
@PrePersist
@PreUpdate
private void prepareIndex() {
if (parent != null) {
index = parent.children.indexOf(this);
}
}
}