I’m currently using ActiveAndroid, and have been trying to get a many-to-many relationship to work for the past few hours, however I just can’t get it to work. I hope you ca
If I change the cast of (Student) to (StudentCourse) I get the following error...
The cast should actually be to (List, but the real problem is in the logic of your model here. You are calling executeSingle(), but you really want multiple StudentCourse objects so that you get every Student-Course relationship for the Course. Your students() and courses() methods don't make much sense, since one StudentCourse object only has one Student and one Course.
I would do it like so instead:
List enrolments = new Select().from(StudentCourse.class).where("course = ?",selectedCourse.getId()).execute();
List studentsInCourse = new ArrayList();
for(StudentCourse enrolment:enrolments)
studentsInCourse.add(enrolment.student);