Consider I have such SQL query:
SELECT t1.* FROM table1 t1 LEFT JOIN table2 t2 ON t1.table2_id = t2.id
WHERE t2.value = 'something' OR t1.value = 'something';
I need the same thing done in HQL query.
More info: Say I have classes Table1 and Table2 both having field named value and Table1 having a field table2 of class Table2. What I want is to get a list of Table1 objects that have certain value or it’s member table2 has certain value and I know that table2 field might be null.
I have tried to formulate the question as clearly as I could without trying to explain every single way I tried to do that without success. Sorry if it is not very clear.
Working example:
Additional note:
If using grails one has to use executeQuery method as findAll will not be enough.
There may be other solutions that I do not know. If you want to share a better solution, please do.