Ниже приведен фрагмент кода из разных файлов проекта
ProjectRepository.java
@Query(value=" SELECT p.id as project_id,p.project_status, t.id as test_suite_id, t.test_suite_status, ts.id as test_script_id,ts.test_script_status, tss.id as test_step_id, tss.test_step_status FROM project p LEFT OUTER JOIN test_suite t ON (p.id = t.project_id AND t.test_suite_status = 1) LEFT OUTER JOIN test_script ts ON (t.id = ts.test_suite_id AND ts.test_script_status=1) LEFT OUTER JOIN test_step tss ON (ts.id = tss.test_script_id AND tss.test_step_status=1) where p.team_id=:teamId and p.project_status=1 ",nativeQuery=true)
public List<Object> getActiveProjectsWithTeamId(@Param("teamId") Long teamId);
projectService.java
List<Object> findActiveProjectsByTeamId(Long id) throws DAOException;
projectServiceImpl.java
@Override
@Transactional(readOnly = true)
public List<Object> findActiveProjectsByTeamId(Long id) throws DAOException {
log.info("entered into ProjectServiceImpl:findOneByTeamId");
if (id != null) {
try {
// returns all projects of the specified team whose
// project_status is active
List<Object> project=projectRepository.getActiveProjectsWithTeamId(id);
return project;
} catch (Exception e) {
log.error("Exception raised while retrieving the project of the mentioned ID from database : "
+ e.getMessage());
throw new DAOException("Exception occured while retrieving the required project");
} finally {
log.info("exit from ProjectServiceImpl:findOneByTeamId");
}
}
return null;
}
Я получаю ниже Output-
[ [ 1, true, 1, true, null, null, null, null ], [ 1, true, 2, true, null, null, null, null ], [ 1, true, 3, true, null, null, null, null ], [ 1, true, 5, true, null, null, null, null ], [ 1, true, 6, true, null, null, null, null ] ]
, но я хочу получить результат в паре ключ-значение