json - object to json in spring
问题描述
Below is the code snippet from different project files
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;
}
I am getting below 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 ] ]
but I want the result in key value pair
解决方案
推荐阅读
- ios - 如何在继续快速之前强制执行firebase功能
- machine-learning - 在元学习期间,什么时候除以 MAML 的 meta_batch_size?
- c# - 使用 FluentValidation 访问验证多个字段的数据库
- node.js - 为什么我的 Node.js 程序会跳过 fs.readFileSync 函数?
- python - 如何在熊猫中将长数据转换为宽数据?
- google-sheets - BigQuery Google Sheets Connected Sheets 数据透视表权限
- node.js - 如何使用 NX(反应和节点应用程序)进行 dockerize?
- java - 使用 MapStruct 映射嵌套的原始列表
- php - php ftp_put 先运行上传文件,再运行false
- python - 如何将pyodbc连接到Docker中的远程MySQL服务器?