行映射器/转换器在春季启动时将对象数组列表转换为json

时间:2020-07-01 05:55:48

标签: java mysql json stored-procedures spring-data-jpa

我有一个mysql stored procedure,它连接多个表并返回一个表。我正在从stored procedure Spring data-{p>中调用repository

@Query(value = "CALL get_emp_details(:id);", nativeQuery = true)
     public List<Object[]> getEmpDetails(@Param("id") long id);

上述方法返回List<Object[]>

[[1890372504,0,"emp.new4444@gmail.com","GB","FUND","GRP280150","GBP","090950a4-ea97-4dc0-b109-702000c47c16","Org-258","GRP280150",1],[1890372504,0,"emp.new4444@gmail.com","GB","FUND","GRP280150","GBP","89d7a44f-b9b7-4d06-b8c2-137d4e7b8e8a","Org-258",null,1]

我要将Employee 1890372504的对象数组列表转换为json。 关于如何实现这一点的任何想法?感谢帮助。

1 个答案:

答案 0 :(得分:0)

请注意操作步骤

get_emp_details(:id)

select查询应具有与实体类(POJO)属性相同的“ as”子句,即employee and replace

列出<对象[]>列出<雇员>