0

I have a HQL query in join between 2 table, with field1 that may be null or with value.

If it is null in first table I have to check if in the second table 'is null' but if it is with value I have to check if table1.field1=table1.field1

How can I do this with 'Case When' in HQL?

soorapadman
  • 4,451
  • 7
  • 35
  • 47
N. Var
  • 3
  • 1
  • 5

1 Answers1

0

I think the HQL query should be something like this:

SELECT t1 FROM Table1 t1, Table2 t2
WHERE t1.t2 = t2 AND
t1.field1 = (CASE WHEN t2.field1 is null THEN NULL ELSE t2.field1 END)
Kirill
  • 1,540
  • 4
  • 18
  • 41