• 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


 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!