-->
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.  [ 7 posts ] 
Author Message
 Post subject: hql question
PostPosted: Fri Jan 23, 2004 8:36 am 
Beginner
Beginner

Joined: Wed Sep 24, 2003 11:16 am
Posts: 20
Location: Turkey
Hi,
I have a class named "Configuration" which has "nodes" collection, which is a component collection.The component (SdhNode) that comprises the elements of nodes collection has many to one association to class "Salon".
I would like to run a query that returns the Configuration instances that has both salon1 and salon2 (which are instances of Salon class) in their nodes.
How can this query be represented with HQL?
Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 23, 2004 1:10 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
I suppos salon1 and salon2 are both objects you allready have? Try something like this:

select c from Configuration c join c.nodes as node where :salon1 in elements(node.salons) and :salon2 in elements(node.salons)

Let me know if this works, it is just off my head.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 25, 2004 11:30 am 
Beginner
Beginner

Joined: Wed Sep 24, 2003 11:16 am
Posts: 20
Location: Turkey
thanks but i think there is a misunderstanding. a node doesn't have many salons. a node has only one salon as many to one association. actually i am searching for the Configuration instance, which satisfies both queries below;

from SdhKonfigurasyon as konf join konf.nodes as node where node.salon=:salon1
from SdhKonfigurasyon as konf join konf.nodes as node where node.salon=:salon2

cheers,
Ahmet


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 26, 2004 1:52 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Does this work ?
Code:
from SdhKonfigurasyon as konf join konf.nodes as node where node.salon in(:salon1, :salon2)

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 26, 2004 4:00 am 
Beginner
Beginner

Joined: Wed Sep 24, 2003 11:16 am
Posts: 20
Location: Turkey
nope. that query finds SdhKonfigurasyon instances that either satisfies query 1 or query 2 I have mentioned in previous post. the instance i am seeking is SdhKonfigurasyon which has both salon1 and salon2 as salon property in its nodes


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 26, 2004 5:33 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
How about this one:

Code:
from SdhKonfigurasyon as konf join konf.nodes as node join konf.nodes as node2 where node.salon = :salon1 and node2.salon = :salon2


Top
 Profile  
 
 Post subject: great!
PostPosted: Mon Jan 26, 2004 7:36 am 
Beginner
Beginner

Joined: Wed Sep 24, 2003 11:16 am
Posts: 20
Location: Turkey
thanks a lot! this one works.


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