If I do something like this :
Code:
public class User {
...
   @OneToMany(cascade={CascadeType.ALL}, fetch=FetchType.EAGER)
   @OrderColumn(name="orderId")
   @JoinColumn
   private List<Test> test = new ArrayList<Test>();
...
}
public class Test {
...
// Get/set
...
   private Integer orderId;
   
   private String text;
   @Id @GeneratedValue private Long id;
}
Hibernate will auto generate orderID.
After creating some test if I go into the database  which looks like this :
Code:
id   orderID text   user_id
41   0   0   5
42   1   1   5
43   2   2   5
44   3   3   5
45   4   4   5
46   5   5   5
47   6   6   5
48   7   7   5
49   8   8   5
50   9   9   5
And move the orderID from 9 to 8, 
Code:
id   orderID text   user_id
41   0   0   5
42   1   1   5
43   2   2   5
44   3   3   5
45   4   4   5
46   5   5   5
47   6   6   5
48   7   7   5
49   8   8   5
50   8   9   5  <-- Now orderID 8
If I do a simple get of the user and then for each on all "Test" it will print
Code:
0
1
2
3
4
5
6
7
9
If I change from @OrderColumn to @OrderBy without deleting generated table, it works. I get 1 to 9 with 8. But if I start anew (drop table) and put @OrderBy, it does not auto generate orderID.
Is there anyways to let Hibernate autogenerate orderID and still let me fetch every entry, or do I have to handle the order id myself?