I execute current this JPQL query
select distinct entity
from Incidence entity
left join treat(entity.road as Road) as road
where entity.road is not null and lower(road.nomenclature) like ?1
looking on log file, this generate this query for PostgreSQL:
select
distinct
....
....
from public.incidence incidence0_
left outer join public.road road1_
on incidence0_.road=road1_.id and null=null
where (incidence0_.road is not null) and (lower(road1_.nomenclature) like ? )
Using '%CV%' as parameter, this query should return 175 rows, but I get none.
If I run the query commenting the " and null=null" on PostgreSQL I get the expected result:
select
distinct
....
....
from public.incidence incidence0_
left outer join public.road road1_
on incidence0_.road=road1_.id /* and null=null */
where (incidence0_.road is not null) and
(lower(road1_.nomenclature) like '%CV%' )
So... Why hibernate adds the "null=null" condition to left join?
I've tried it with Oracle and I got the very same result.
|