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";
您必须加入第二个表:
SELECT e FROM Foo f JOIN f.elements e ORDER BY e.bar
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.