eclipselink - OneToMany + JoinTable + OrderColumn: Order is written correctly but not read -


i have entity can consist of itself:

class group {     // ...     @onetomany(cascade = cascadetype.all, orphanremoval = true)     @jointable(         name = "group_group",         joincolumns = @joincolumn(name = "id"),         inversejoincolumns = @joincolumn(name = "parentgroup_id")     )     @ordercolumn     private list<group> groups = new arraylist<group>();      @manytoone     private group parentgroup;      public list<group> getgroups() {         return groups;     }      public group getgroup() {         return parentgroup;     } } 

i can create group , add 2 child groups:

group parent = new group(); group child1 = new group(); group child2 = new group();  parent.getgroups().add(child1); parent.getgroups().add(child2);  parent = grouprepository.save(parent);  // parent.getgroups().get(0).getid() == child1.getid() // parent.getgroups().get(1).getid() == child2.getid() 

but seems coincidence. able update order (e.g. using collections.sort) , join table rows updated correctly.

it not matter how load parent group, child groups in order of creation. executed sql query is:

select t1.id, t1.parentgroup_id group t0, group t1 ((t1.parentgroup_id = ?) , (t0.id = t1.parentgroup_id)) 

there no order seems wrong. how can persuade eclipselink add it?

the problem tried load child group entities using crudrepository. repository ignores @ordercolumn annotation. fixed fetching parent group , using getgroups().


Comments