-->
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.  [ 4 posts ] 
Author Message
 Post subject: HQL class clause
PostPosted: Wed Jan 18, 2006 8:25 pm 
Senior
Senior

Joined: Wed Jun 15, 2005 4:17 am
Posts: 156
Hello all,

Is there someone who has used the class clause in a HQL query in NHibernate? Something like this one (taken from the Hibernate docs):
Code:
from eg.Cat cat where cat.class = eg.DomesticCat


While there is no explicit entry in JIRA, it seems that the HQL parser has a bug as it doesn't generate the correct SQL for it. I would like to know if anyone has successfully used the class clause in HQL in NHibernate.

cheers,
radu


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 19, 2006 3:46 am 
Regular
Regular

Joined: Mon Jul 18, 2005 4:10 am
Posts: 92
Location: Poland
Hi,

I have one query with "class" in where and it performs well. The resulting sql is "where discriminator_column = 'discriminator_value'" (you can't use class if there is no discriminator used)

_________________
michal


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 19, 2006 6:52 am 
Senior
Senior

Joined: Wed Jun 15, 2005 4:17 am
Posts: 156
my class hierarchy uses the table per subclass mapping strategy so there is no discriminator. What I've noticed is that the generated SQL (I'm using SQL Server 2000 dialect) has a slight error in the generated where clause which corresponds for the "class" clause: instead of checking for the class I specified it checks for the base class.

Anyone has used the "class" clause with a class hierarchy mapped with the table per subclass strategy? It seems that I should build a simple test case to prove the bug and submit it to Jira...

cheers,
radu


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 19, 2006 2:41 pm 
Regular
Regular

Joined: Mon Jul 18, 2005 4:10 am
Posts: 92
Location: Poland
Sorry, but I'm afraid it is not a bug - look at the sentences above mentioned example in the docs :
Quote:
Likewise, the special property class accesses the discriminator value of an instance in the case of polymorphic persistence. A Java class name embedded in the where clause will be translated to its discriminator value.

In my opinion (based on the above) the usage of "class" is limited to table-per-class hierarhy strategy, at least in 2.x version of Hibernate (which NH ports)

Somebody please correct me if i'm wrong.

_________________
michal


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

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.