HQL, left join in one table

I am looking for a way to make a left join with the same table with hql.

This is my request.

  FROM Tvshow e
  LEFT JOIN Tvshow e1 ON e1.num = e.num
 WHERE e1.code = '024'
   AND e.code is not null
   AND e.code != '024'

Sleep mode is not like an operator.

+5
source share
2 answers

Left connections in HQL are only possible if you have a connection between two objects. Since your query imposes a merged entity on a nonempty entity, the inner join will do the same. An inner join with join syntax is also only possible if you have a relationship between two objects. But you can do this by simply adding an equality test to the where clause:

select e from Tvshow e, Tvshow e1
where e.num = e1.num
and e1.code = '024'
and e.code is not null
and e.code != '024'
+4
source

I do not use sleep mode, but judging by this example:

from Cat as cat
inner join cat.mate as mate
left outer join cat.kittens as kitten

: http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/queryhql.html#queryhql-joins-forms

, ON? , , .

FROM Tvshow e
  LEFT JOIN Tvshow e1 
 WHERE e1.code = '024'
   AND e.code is not null
   AND e.code != '024'
0

All Articles