I have defined a JPA entity “A” with a @ManyToOne relationship to another JPA entity “B”.
@Entity
class A {
String name;
int sortOrder
@ManyToOne
B b;
}
This reference can be null or it can be populated. Now, I would like to query all the As and sort by B.name. Unfortunately, something like
find("order by B.name, sortOrder, name")
seems to drop any As such that (A.b = null). What is the best way to write this query?
I want all the As and I want them sorted by their B.name reference if it exists … lumping all those with no B property together.
you need a left join.
or something like that.