-->
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.  [ 2 posts ] 
Author Message
 Post subject: HQL to Many To Many
PostPosted: Thu Apr 13, 2006 2:39 pm 
Newbie

Joined: Thu Jan 12, 2006 5:22 pm
Posts: 6
Hello!

I have a many-to-many relashionship: Principal <-> Roles. How can I use HQL to get all the Roles from a particular Principal? I am doing this:

Quote:
from Roles e where e.Principals.Id = 1


All the properties in the HQL exist. This does not work, how can I do what I want?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 14, 2006 4:04 am 
Regular
Regular

Joined: Tue Mar 15, 2005 12:38 pm
Posts: 73
Location: Bucharest
from Roles e inner join e.Principals p where p.Id = 1

or

select elements (p.Roles) from Principal p where p.Id = 1

The reason your query does not work is that you cannot traverse collection association with . (dot). So book.Pages.PageNumber is not correct becase Pages is a collection, but book.Author.OriginCountry.Name is correct because all are many-to-one..

_________________
Dragos


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