I tried to add together=true to my code. The outcome is the same as without it. Then I tried to pass string value to an int parameter. But I still get same ‘null’ results and without any error report. So I suppose that the findAll returns before send any request to the database.
You don’t have to specify ‘together’ when there’s no ‘OFFSET’ or ‘LIMIT’ in the condition. ‘with’ is enough for the current scenario.
I would try the plain sql for debugging. Something like …
select * from subject
join user_subject on subject.id = user_subject.subject_id
join user on user_subject.user_id = user.id
where user_id = 1 and role = 1 and usn >= 1 and usn <= 20
Does it really return some records? Or, is empty result the correct outcome?