Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Many to Many query

 
Romeo Sheshi
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have the tables "Student" and "Course" and the join table "student_course".

I need to make a query with criteria to find only students that have both "java" and "html". In this case only the student with name "marco"

 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What have you tried?

Why not create a Restriction? Do two Restrictions on the name field, and set them for java and html. Then I think there is a junction or disjuntion property that will bring back the and results from the query. That should do it!

Here's a little tutorial on performing Hibernate Critieria Queries. You might find it helpful:

Doing Queries with the Hibernate Criteria API

-Cameron McKenzie


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic