Hibernate version: 1.2.0beta2
Mapping documents:
N/A - a base class (EEvent) with some joined-subclasses (EPoiEvent, EGeoEvent...)
Name and version of the database you are using:
SQL Server 2000 SP3
I'm facing a problem trying to filter a result in a HQL query based on .class meta-property, what i do is basically that:
from Domain.EEVent e where e.class in (Domain.EGeoEvent, Domain.EStateEvent, Domain.EPoiEvent)
i tried even
from Domain.EEVent e where e.class = Domain.EGeoEvent AND ....
The SQL in output is
select eevent0_.id [ columns omitted for clarity ]
case when eevent0_1_.id is not null then 1 when eevent0_2_.id is not null then 2 when eevent0_3_.id is not null then 3 when eevent0_4_.id is not null then 4 when eevent0_5_.id is not null then 5 when eevent0_.id is not null then 0 end as clazz_
from event eevent0_
left outer join event_driver eevent0_1_ on eevent0_.id=eevent0_1_.id
left outer join event_geo eevent0_2_ on eevent0_.id=eevent0_2_.id
left outer join event_state eevent0_3_ on eevent0_.id=eevent0_3_.id
left outer join event_poi eevent0_4_ on eevent0_.id=eevent0_4_.id
left outer join event_geostate eevent0_5_ on eevent0_.id=eevent0_5_.id
where
((case when eevent0_1_.id is not null then 1 when eevent0_2_.id is not null then 2 when eevent0_3_.id is not null then 3 when eevent0_4_.id is not null then 4 when eevent0_5_.id is not null then 5 when eevent0_.id is not null then 0 end = 0 )) order by eevent0_.event_datetime ASC
That SQL is pretty well mistaken, as we can see in the where condition (here i was looking for EPoiEvent only, so the = after the case end should be 4 and not 0)
I would know what is the better way to filter for MULTIPLE class discriminator, like i'm trying to do, and in case, if this is a bug
Thanks in advance,
|