0

I have a little question about sorting on OneToMany relationship. Here is the sample code. I would like to have all of the results of class A sorted according to C.title. What is the correct syntax?

Example:

=========
@Entity
@Table (name = "A")
public class A extends Domain {
...
@OneToMany (mappedBy = "B")
@OrderBy ("C.title")
public ArrayList<B> results = new ArrayList <> ();
..
}
=========
@Entity
@Table (name = "B")
public class B extends Domain {
...
@ManyToOne (mappedBy = "C")
public C results;
..
}
=========
@Entity
@Table (name = "C")
public class C extends Domain {
...
private string title;
..
}
  • 2
    you should use "results.title" instead of "C.title". "results" refers to the list of C in class B – cool Jul 28 '20 at 11:23
  • ora-01747 invalid user.table.column table.column or column specification :l – TheQuestionIs Jul 28 '20 at 11:32
  • My bad it looks like it only works with direct properties or embedded attributes https://stackoverflow.com/questions/1105099/defining-the-order-of-a-list/1105370#1105370 – cool Jul 28 '20 at 11:40

0 Answers0