1
I have a Product Entity regarding @Manytoone. And I need to bring the last child record of each parent. I made a select in the table and this bringing what I need more I’m not right to do the same query with hql.
This is my select in mysql:
SELECT p1.id,p1.description,p1.code,p1.note,p1.owner_id FROM
product AS p1 LEFT JOIN product AS p2
ON p1.id = p2.owner_id
WHERE p2.owner_id IS NULL;
And this consultation and how I’m trying to do in the hql:
("SELECT E FROM " + Product.class.getSimpleName()
+ " E LEFT JOIN " + Product.class.getSimpleName()
+ " P ON E.id = P.owner_id"
+ " P WHERE P.owner_id IS NULL");
Hello the AS makes no difference.
– Alexandre Ferreira
Yes, another option in place of
AS
is to put the name of the direct variable, but there is a personal criterion."SELECT E FROM " + Product.class.getSimpleName() + " E"
 + " LEFT JOIN " + Product.class.getSimpleName() + " P"
]– brow-joe