Reputation: 3778
Im having a self reffering datamodel. Im trying to get a list of children ordered by an attribute using JPA (Hibernate). But Im having problems with the JPQL. Do you have a suggestion on how I can solve this?
Entity
@Entity
public class Foo {
private String bar;
private List<Foo> elements;
}
JPQL
Demo JPQL to give you a hint of what Im trying to do
String jpql = "SELECT f.elements " +
"FROM Foo f " +
"Order By f.elements.bar";
Upvotes: 1
Views: 5485
Reputation: 1892
You have to join the second table:
SELECT e FROM Foo f JOIN f.elements e ORDER BY e.bar
Upvotes: 5