-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Problem with HQL and .class meta-property
PostPosted: Wed Feb 14, 2007 11:59 am 
Newbie

Joined: Tue Oct 24, 2006 2:51 pm
Posts: 19
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,


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.