I have a ClassRoom
class, in my Spring Boot application. Here is what it looks like :
public class ClassRoom {
@Id @GeneratedValue Long classRoomID;
ArrayList<User>adminList=new ArrayList<>();
}
And in my ClassRoomRepository
class, I have :
public interface ClassRoomRepository extends JpaRepository<ClassRoom,Long> {
@Query("select ClassRoom from ClassRoom c where c.adminList = ?1")
ArrayList<ClassRoom> findByAdminList(ArrayList<User> adminList);
/*
@Query("select ClassRoom from ClassRoom c where c. = ?1")
ArrayList<ClassRoom> findByAdmin(User admin);
*/
}
I can query to select ClassRoom
where ArrayList
of ClassRoom
gets passed parameter.
But I want to query to select ClassRoom where
I pass only one User
as parameter and returns ArrayList
of ClassRoom
.(Commented section-nothing done so far)
If it is possible in this interface, how can I do so?