用的oracle数据库,在dao操作中不用自己写sql,如何加去除null值的条件
andEX("is", "not", "null")这是直接在sql后边拼接的字符串,日志打印语句出错
"SELECT * FROM table WHERE id='1' AND is NOT 'null'"
比如有表tb 表内容是 1 2 3 4 5 (NULL) (NULL) (NULL) ...... (一条记录)
我用select * from tb 取过来的值就把这些空值(NULL)也取过来了 我想要自动舍弃空值 比如例子中就取到 1 2 3 4 5 这里结束 sql语句条件要怎么加?
我是要查出这一行的记录,去掉为null的值,只要有数据的值
假如有表
name age sex salary
aa null 1 null
我要查出来的数据是 name : aa sex : 1 其他没值的不要
{
"id": "4",
"name": "ddd",
"type": "type4",
"parentCategoryid": "1",
"categoryUrl": "xxx",
"createAt": 1111,
"updateAt": 2222,
"unitId": "007",
"coordinateSystem": "wgs84",
"descinfo": "9999",
"metadataid": "1",
"disable": "0",
"delflag": "0",
"resourceMetadate": {
"id": "1",
"count": 3,
"descinfo": "11111",
"createAt": 1102,
"templateId": "1",
"item1": "x1",
"item2": "x2",
"item3": "x3",
"item4": null,
"item5": null,
"item6": null,
"item7": null,
"item8": null,
"item9": null,
"item10": null,
"item11": null,
"item12": null,
"item13": null,
"item14": null,
"item15": null,
"item16": null,
"item17": null,
"item18": null,
"item19": null,
"item20": null,
"metadataModel": {
"id": "1",
"count": 3,
"createUnitid": null,
"createAt": 0,
"responsableperson": null,
"descinfo": null,
"item1": "xx1",
"item2": "xx2",
"item3": "xx3",
"item4": null,
"item5": null,
"item6": null,
"item7": null,
"item8": null,
"item9": null,
"item10": null,
"item11": null,
"item12": null,
"item13": null,
"item14": null,
"item15": null,
"item16": null,
"item17": null,
"item18": null,
"item19": null,
"item20": null
}
}
}
@At("/showTree")
@Ok("json:{ignoreNull:true}")
public Object tree(@Param("pid") String pid) {
if(Strings.isBlank(pid)){
pid = "0";
}
List list = resourceService.query(Cnd.where("parentCategoryid", "=", pid));
List<Map<String, Object>> tree = new ArrayList<>();
Map<String, Object> obj = new HashMap<>();
for (ResourceDefine unit : list) {
obj = new HashMap<>();
obj.put("id", unit.getId());
obj.put("text", unit.getName());
obj.put("children", true);
tree.add(obj);
}
return tree;
}
}