java - Order by not working for child objects in Hibernate -


i want retrieve child objects sorted on particular column.
have parent class student

public class student {      @id      @generatedvalue(strategy=generationtype.auto)     @column(name="student_id")     private long studentid;       @column(name="student_name")     private string studentname;      @onetomany(mappedby="student")     private list<phone> studentphonenumbers ;  } 

and child class phone

public class phone {      @id      @generatedvalue(strategy=generationtype.auto)     @column(name="phone_id")     private long phoneid;       @column(name="phone_no")     private string phonenumber;      @column(name ="update_tmstp")     private date updatetmstp;      @manytoone     @joincolumn(name = "student_id")     private student student; } 

i fetching student object in turns gives me list of phone nos. , want phone nos sorted based on column updatetmstp wrote this

student stu = (student)session.createcriteria(student.class)                 .createalias("studentphonenumbers", "st").addorder(order.desc("st.updatetmstp")).uniqueresult(); 

but not working. can me. did wrong?

under studentphonenumbers place orderby annotation , on query use join fetch bring phones eagerly.

be aware means fecth on studentphonenumbers allways generate select ... order by. if that's not want suggest sort collection in code after results.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -