Home Springboot jpa, get rows with specific fields using two joins
Reply: 0

Springboot jpa, get rows with specific fields using two joins

user630
1#
user630 Published in April 25, 2018, 6:11 pm

I have entities :Student, Class, Room.

student M-M class, student M-M rooms, thus two junction tables. Now I want to get all students assigned to class X and room Y. Thus I've made:

@Query("SELECT s from Student s INNER JOIN s.classes c INNER JOIN s.rooms r WHERE c.id LIKE ?1 AND r.id LIKE ?2")
Page<Student> findAllInClassAndRoom(final Long classId, final Long roomId, final Pageable pageable); 

But it gives me wrong results. Is there an error in my query ?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.304242 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO