I am trying to create parent child tables where the order is preserved. The example 7.8 from Hibernate documentation shows how to do this:
@Entity
public cl
Do something like this:
@Entity
class Parent {
@OneToMany
@IndexColumn(name = "index_column")
List children;
}
@Entity
class Child {
@ManyToOne
Parent parent;
@Column(name = "index_column")
Integer index;
@PrePersist
@PreUpdate
private void prepareIndex() {
if (parent != null) {
index = parent.children.indexOf(this);
}
}
}