-->
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.  [ 1 post ] 
Author Message
 Post subject: Criteria query and many-to-many
PostPosted: Tue Jul 07, 2009 12:44 pm 
Newbie

Joined: Tue Jul 07, 2009 12:33 pm
Posts: 5
Hi

I have two tables, MOVIES and MOVIES_GENRES (also also GENRES that is not important in this topic).

Here's a brief schema:

MOVIES
- MOVIE_ID
- TITLE

MOVIES_GENRES
- MOVIE_ID
- GENRE_ID

Each movie can belong to multiple genres, e.g. drama, action, sci-fi, horror, etc.

Now, I want to be able to get all movies in the "action" and "sci-fi" genre.

I'm trying to do this using a Criteria query, and have the class set-up in xml like this:
Code:
    <set cascade="all" inverse="true" name="genres" table="MOVIES_GENRES">
      <key column="MOVIE_ID"/>
      <many-to-many class="Genre" column="GENRE_ID"/>
    </set>


and then where I do the Criteria query:
Code:
criteria.add(Expression.in("genres", new String[] {"sci-fi","action"}));



But of course this is not working, I keep getting: "Missing IN or OUT parameter at index:: 3"


Please help me find my mistake, and/or point me to the best way of accomplishing a query like this.

Thank you.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.