-->
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: Query a list attribute with hql
PostPosted: Sat Mar 29, 2008 5:46 pm 
Newbie

Joined: Sat Mar 29, 2008 1:31 pm
Posts: 8
Hello.

I am pretty new to Hibernate and have some problems with a HQL query.
I have persisted some objects, which have a structure like this:

class Document:
long id
List<String> tags

Now I want to query all tags of all documents.
It isn't important if the result is a list of lists or all tags together in one list.

An easy query like "doc.tags from Document as doc", doesn't solve the problem. I get an exception, that tags is not an entity.
The data is there. All in a document_tags table. A normal SQL query would be easy, but how do I fetch it with HQL? Can someone help me out?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 29, 2008 5:55 pm 
Newbie

Joined: Sat Mar 29, 2008 1:31 pm
Posts: 8
Sorry, my posting was a bit too fast. I finally found the solution after trying many query strings.
select tags from Document as doc inner join doc.tags as tags


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.