This commit is contained in:
Redkale
2020-01-30 11:44:46 +08:00
parent ee8a18a528
commit 6560e71e48
2 changed files with 13 additions and 1 deletions

View File

@@ -174,9 +174,11 @@ public class DataJdbcSource extends DataSqlSource<Connection> {
prestmt.setObject(++i, ((AtomicInteger) val).get());
} else if (val instanceof AtomicLong) {
prestmt.setObject(++i, ((AtomicLong) val).get());
} else if (val != null && !(val instanceof Number) && !(val instanceof CharSequence) && !(entity instanceof java.util.Date)
} else if (val != null && !(val instanceof Number) && !(val instanceof CharSequence) && !(val instanceof java.util.Date)
&& !val.getClass().getName().startsWith("java.sql.") && !val.getClass().getName().startsWith("java.time.")) {
prestmt.setObject(++i, info.jsonConvert.convertTo(attr.genericType(), val));
} else if (val == null && info.isNotNullJson(attr)) {
prestmt.setObject(++i, "");
} else {
prestmt.setObject(++i, val);
}

View File

@@ -1084,6 +1084,16 @@ public final class EntityInfo<T> {
return attr == null ? false : notNullColumns.contains(attr.field());
}
public boolean isNotNullJson(Attribute<T, Serializable> attr) {
if (attr == null) return false;
return notNullColumns.contains(attr.field())
&& !Number.class.isAssignableFrom(attr.type())
&& !CharSequence.class.isAssignableFrom(attr.type())
&& java.util.Date.class != attr.type()
&& !attr.type().getName().startsWith("java.sql.")
&& !attr.type().getName().startsWith("java.time.");
}
/**
* 判断日志级别
*