-->
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.  [ 3 posts ] 
Author Message
 Post subject: HQL questions
PostPosted: Wed Dec 28, 2005 11:49 am 
Newbie

Joined: Sat Oct 22, 2005 4:17 am
Posts: 7
NHibernate version: 1.0.0

Mapping documents:
<bag name="channels" table="CHANNELS2PLANNED_BROADCASTS" order-by="CHANNELS_FK" inverse="false">
<key foreign-key="CHANNEL_PLANNED_BROADCASTS_FKC">
<column name="PLANNED_BROADCASTS_FK" />
</key>
<many-to-many class="xxx.Channel, xxx" foreign-key="PRESENTATION_CHANNELS_FKC">
<column name="CHANNELS_FK" />
</many-to-many>
</bag>


<joined-subclass name="xxx.ScheduleRule, IQuality.FutureCast" table="SCHEDULE_RULE" dynamic-insert="false" dynamic-update="false">


Code between sessionFactory.openSession() and session.close():
Session.find(pHql);


Hello,
i've have some problems with NHibernate with builder my hql-queries.

1) I want to select all Presentations with had a relation with a specific Channel. Presentation an Channel have a many-to-many relation. But it won't work :(

I can't call the Channel directly, like: from Presentation presentation where presentation.channels.id = 1.
I also tried a join: from Presentation presentation inner join presentation.channels where channel.id = 1.

I can't/won't use an ICritera, because this is a part of a query.



2) I want to get alle specialisations of a association. ScheduleRule extends Rule and Presentation has a one-to-many relation with Rule.

I tried this, wich stands in my Hibernate book "professional hibernate":
from Rule rule where rule.class = ScheduleRule

I doesn't give an exception, but only an empty list. But there are ScheduleRules! This was an example with Hibernate (java), but it won't work in NHibernate.

Can someone help me with these queries?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 28, 2005 12:05 pm 
Newbie

Joined: Sat Oct 22, 2005 4:17 am
Posts: 7
can't i edit my own message?

But the first query is working, i forgot something in my frustration...

inner join presentation.channels channel
that's working


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 28, 2005 3:46 pm 
Expert
Expert

Joined: Fri Oct 28, 2005 5:38 pm
Posts: 390
Location: Cedarburg, WI
Yes, you must alias joins if you want to filter by them or join again to them. It's a good practice to always alias every entity and join in the FROM clause.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.