Hi.
I'm trying to write an hql query that does something like this:
"from Data as data where (data.info is null or data.info.startDate > :timestamp)"
I am working with HSQLDB.
The problem is that the result ignores the cases in which data.info IS null.
I've noticed that the HQL is translated to SQL like this:
Code:
select
data0_.DATA_ID as DATA1_32_,
data0_.INFO_ID as INFO3_32_,
data0_.name as name32_
from
DATA data0_,
INFO info1_
where
data0_.INFO_ID=info1_.INFO_ID
and (
data0_.INFO_ID is null
or info1_.startDate>?
)
And it seems that the "data0_.INFO_ID=info1_.INFO_ID" part causes the problem.
In contrast, when I use the query
"from Data as data where (data.info is null)" I get the following sql:
Code:
select
data0_.DATA_ID as DATA1_32_,
data0_.INFO_ID as INFO3_32_,
data0_.name as name32_
from
DATA data0_
where
data0_.INFO_ID is null
Which does retrieve the null objects.
Sadly, I cannot use some patch like creating an empty "info" class for every "data" to avoid the problem.
Is there any way to write a single query in which the where clause is in the form "x is null or x.y = value" (or some workaround for the problem)?
Regards,
Oz