-->
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.  [ 5 posts ] 
Author Message
 Post subject: Select a song with the tags Blackmetall AND Didgeridoo
PostPosted: Sun Feb 28, 2010 10:52 pm 
Newbie

Joined: Sun Nov 15, 2009 8:22 pm
Posts: 19
Ok so easy question probably, but I had an accident with the microwave and now my brain is all messed up.

A Song has Tags on it.

class Song {
List<Tag> tags;
}

and I want to be able to select a song that has 1 or more specified tags.

i.e. only show the songs that have the tag Blackmetall, or show only the songs that have the tags Blackmetall AND Didgeridoo.

Could be more than 2 tags.

Thanks!


Last edited by sore on Tue Mar 02, 2010 12:38 pm, edited 2 times in total.

Top
 Profile  
 
 Post subject: Re: Select a song with the tags Blackmetall AND Didgeridoo
PostPosted: Mon Mar 01, 2010 6:17 am 
Newbie

Joined: Sun Nov 15, 2009 8:22 pm
Posts: 19
Anyone??

I have this, but its not working at all

Code:
criteria.createAlias("tags", "tagsAlias");
Junction junc = Restrictions.conjunction();

for (Tag tag : tags) {
if (tag != null && tag.getId() != null) {
   junc.add(Restrictions.like("tagsAlias.id", tag.getId()));

   }
}


Top
 Profile  
 
 Post subject: Re: Select a song with the tags Blackmetall AND Didgeridoo
PostPosted: Mon Mar 01, 2010 12:14 pm 
Newbie

Joined: Sun Nov 15, 2009 8:22 pm
Posts: 19
The same question here in this thread, except my problem is a many to many link

viewtopic.php?f=1&t=1002055&p=2423564&hilit=createAlias#p2423564

but no answer there. Should be a easy one, could someone give some directions???


Top
 Profile  
 
 Post subject: Re: Select a song with the tags Blackmetall AND Didgeridoo
PostPosted: Tue Mar 02, 2010 12:39 pm 
Newbie

Joined: Sun Nov 15, 2009 8:22 pm
Posts: 19
bump
please someone??


Top
 Profile  
 
 Post subject: Re: Select a song with the tags Blackmetall AND Didgeridoo
PostPosted: Wed Mar 03, 2010 7:31 pm 
Newbie

Joined: Sun Nov 15, 2009 8:22 pm
Posts: 19
So I found a really old issue with this:

http://opensource.atlassian.com/project ... se/HHH-879

apparently duplicate associations are not possible. How do you solve problems like this with criterias??


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