两张表,html表,type表

html的typeId是type的id,在使用@query时一直报错,报Could not write JSON: Null key for a Map not allowed in JSON

网上说是因为key是空导致的,但是能确定每个字段都是名字的,也没有重复的,
后来采用下面的方法将实现层写成下面的代码成功运行
@Autowired
private JdbcTemplate jdbcTemplate;
public List<retHtml> findByLeftJoin(){
String sql = "select a.id ,a.name ,html_Str ,b.name as type_Name ,is_Union ,union_Name ,union_Time ,union_Order ,a.create_Date from Html a left join Type b on b.id= a.type_Id";
List<retHtml> list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(retHtml.class));
return list;
}
同时也发现导致Null key for a Map not allowed in JSON的原因:html_str在数据库中是Clob类型,实体类中也是Clob类型, Clob的字段无法自动转成Map类型,重新定义一个类才可以。
浙公网安备 33010602011771号