若是作報表,一條記錄中有空值,使用FreeMarker渲染word會報錯,並把錯誤日誌輸出到Word中.因此須要以前判斷下當前記錄中屬性值是否有空值.java
package com.huijiasoft.utils; import java.util.Iterator; import java.util.Set; import java.util.Map.Entry; import com.huijiasoft.model.User; /** * @author pangPython * 數據庫工具類 */ public class DBUtils { //判斷數據庫某條記錄的屬性字段是否包含空值 public static Boolean RecordAttrHasNull(User user){ Set<Entry<String, Object>> set = user._getAttrsEntrySet(); Iterator<Entry<String, Object>> it = set.iterator(); while(it.hasNext()){ Entry<String, Object> attr = it.next(); if(attr.getValue()==null){ return true; } } return false; } }
參考原文:https://blog.csdn.net/u012995856/article/details/52890930數據庫