JPA select List<Object> from entity order by list elements attribute

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";

Answers


You have to join the second table:

SELECT e FROM Foo f JOIN f.elements e ORDER BY e.bar

Need Your Help

wx.Panel in a wx.Panel

python wxpython panel wxwidgets

When I embed a wx.Panel in another wx.Panel (here ChildPanel is embedded in MyPanel), by default this ChildPanel doesn't use the full size of the parent. Why?

Python app run using browser

python ide pycharm

I would like to run my python application locally in any web browser. I am using PyCharm IDE for my Python apps but when i run app from IDE, its not running in browser. How it can solve?