一、背景
二、实现
@Autowired
private EntityManager entityManager;
Query query = entityManager.createNativeQuery(sql);
query.unwrap(SQLQuery.class).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
List<Map<String, Object>> reportWaterTota = query.getResultList();
List<SewageVolumeDto> createSmsDtos = JacksonUtils.listMapToListBean(reportWaterTota, SewageVolumeDto.class
); // 数据
public static <R> List<R> listMapToListBean(List<Map<String, Object>> info, Class<R> clazz){
try {
return jsonToList(MAPPER.writeValueAsString(info), clazz);
} catch (JsonProcessingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
}