赞
踩
某一个字段存了一个对象,现在需要查询符合条件的对象出来,例如:查询一个中果的对象,并打印出她的种类。
SELECT * FROM `orange` o WHERE o.content LIKE '%"kind":"中果"%';
String searchCondition = "中果";
List<OrangeEo> orangeEos = orangeMapper.selectList(Wrappers.lambdaQuery(OrangeEo.class).like(OrangeEo::getContent, "\"kind\":\"" + searchCondition + "\""));
log.info("==============orangeEos集合 size:{},集合:{}===========================>", orangeEos.size(),JSON.toJSONString(orangeEos));
if (orangeEos.size() > 1) {
OrangeEo eo3 = orangeEos.get(0);
OrangeCodeDto dto = JSONUtil.toBean(eo3.getContent(), OrangeCodeDto.class);
log.info("==============dto的kind:{}===========================>",dto.getKind());
}
==============orangeEos集合 size:2,集合:[{"content":"{\"kind\":\"中果\",\"size\":8}","id":8},{"content":"{\"kind\":\"中果\",\"size\":8}","id":11}]===========================>
==============dto的kind:中果===========================>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。