spring-data-jpa-guide
spring-data-jpa-guide copied to clipboard
JPA不推荐使用List<Map<String,Object>>作为响应结果
1: 不够结构化,完全不知道里面是什么; 2:可能引起其它bug
老铁们,写自定义QSL的时候,如果不写后面的as xxx,会报JSON NULL无法转换,与字段内容无关,字段都是有值的,是少写了什么东西吗
Map的key为NULL所以报错,打印了一下,确实都是NULL,本意是想把字段名当成key,字段值当成value。
如果加了as xxx就没问题
Resolved [org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON: Null key for a Map not allowed in JSON (use a converting NullKeySerializer?); nested exception is com.fasterxml.jackson.databind.JsonMappingException: Null key for a Map not allowed in JSON (use a converting NullKeySerializer?) (through reference chain: java.util.ArrayList[0]->org.springframework.data.jpa.repository.query.AbstractJpaQuery$TupleConverter$TupleBackedMap["null"])]