I have one Object say Student with following parameter :
Student{
String name;
int marks;
String department;
Subject subject;
//getters and setters
}
I want to get the count(student), department from student group by department using crudRepository.
What will be the return type of the method that we will define in the crudrepository? How should I write the whole flow? I am getting exception.
Below is the code snippet of repository :
@Query("select new com.myProject.MyObject(mec.serviceName, count(mec)) " +
"from migration_entity_count mec where mec.workflowRequestId = :workflowRequestId " +
"group by mec.serviceName order by mec.serviceName")
List<EntitiesByServiceName> getMigrationEntitiesCountByServiceName(@Param("workflowRequestId") Long workflowRequestId);
}
MyObject has 2 paramters : Long and String