Hive查询空值判断Bug修正
This commit is contained in:
@@ -151,12 +151,11 @@ public class HiveJDBC {
|
||||
for (int i = 1; i <= metaData.getColumnCount(); i++) {
|
||||
Object value = rs.getObject(i);
|
||||
String filedName = filedAndColumnMap.get(metaData.getColumnName(i).toString().toLowerCase());
|
||||
if (null != value) {
|
||||
if (!StringUtil.isEmpty(value)) {
|
||||
//如果是日期类型的属性需要把时间戳转换成日期,如果时间戳为0直接把值设置为null
|
||||
if (null != columnList && columnList.contains(filedName.toLowerCase())) {
|
||||
long time = 0l;
|
||||
if (null != value && !value.toString().equals("")) {
|
||||
time = Long.parseLong(value.toString());
|
||||
}
|
||||
time = Long.parseLong(value.toString());
|
||||
map.put(filedName, time==0l?null:new Date(time * 1000));
|
||||
// map.put(filedName, new
|
||||
// Date(Long.parseLong("1476583810000")));
|
||||
@@ -236,7 +235,7 @@ public class HiveJDBC {
|
||||
String fieldTypeName = propertyDescriptor.getPropertyType().getName();
|
||||
if (map.containsKey(name)) {
|
||||
Object value = map.get(name);
|
||||
if (null != value && !value.equals("")) {
|
||||
if (!StringUtil.isEmpty(value)) {
|
||||
if (fieldTypeName.equals("java.lang.String")) {
|
||||
propertyDescriptor.getWriteMethod().invoke(obj, new String[] { value.toString() });
|
||||
} else if (fieldTypeName.equals("java.lang.Integer")) {
|
||||
|
||||
@@ -49,7 +49,7 @@ public class HiveSqlService {
|
||||
}
|
||||
sql.setLength(0);
|
||||
sql.append(" select " + sqlTrim + " from " + tableName + " t where 1=1 ");
|
||||
if (bean != null) {
|
||||
if (!StringUtil.isEmpty(bean)) {
|
||||
Class<?> clazz = bean.getClass();
|
||||
for (; clazz != Object.class; clazz = clazz.getSuperclass()) {
|
||||
// 获取所有的字段包括public,private,protected,private
|
||||
@@ -64,7 +64,7 @@ public class HiveSqlService {
|
||||
String typeName = f.getType().getName();
|
||||
if (f.getType().getName().equals("java.lang.String") && key.startsWith("search")) {
|
||||
Object value = getFieldValue(bean, key);
|
||||
if (value != null) {
|
||||
if (!StringUtil.isEmpty(value)) {
|
||||
setFieldValue(bean, key, value.toString().trim());
|
||||
if (key.endsWith("Time")) {// 日期开始或结束的字段
|
||||
if (col2col.containsKey(key)) {
|
||||
@@ -159,7 +159,7 @@ public class HiveSqlService {
|
||||
String typeName = f.getType().getName();
|
||||
if (f.getType().getName().equals("java.lang.String") && key.startsWith("search")) {
|
||||
Object value = getFieldValue(bean, key);
|
||||
if (value != null) {
|
||||
if (!StringUtil.isEmpty(value)) {
|
||||
setFieldValue(bean, key, value.toString().trim());
|
||||
if (key.endsWith("Time")) {// 日期开始或结束的字段
|
||||
if (col2col.containsKey(key)) {
|
||||
|
||||
Reference in New Issue
Block a user