source
This commit is contained in:
@@ -216,32 +216,20 @@ public interface DataResultSet extends DataResultSetRow {
|
|||||||
public static <T> Serializable getRowColumnValue(
|
public static <T> Serializable getRowColumnValue(
|
||||||
DataResultSetRow row, Attribute<T, Serializable> attr, int index, String column) {
|
DataResultSetRow row, Attribute<T, Serializable> attr, int index, String column) {
|
||||||
final Class t = attr.type();
|
final Class t = attr.type();
|
||||||
Serializable o = null;
|
if (t == byte[].class) {
|
||||||
try {
|
return (byte[]) (index > 0 ? row.getObject(index) : row.getObject(column));
|
||||||
if (t == byte[].class) {
|
} else {
|
||||||
Object blob = index > 0 ? row.getObject(index) : row.getObject(column);
|
Serializable o = (Serializable) (index > 0 ? row.getObject(index) : row.getObject(column));
|
||||||
if (blob == null) {
|
if (o != null) {
|
||||||
o = null;
|
if (t == String.class && o instanceof String) {
|
||||||
} else { // 不支持超过2G的数据
|
return o;
|
||||||
// if (blob instanceof java.sql.Blob) {
|
} else if ((t == Integer.class || t == int.class) && o instanceof Integer) {
|
||||||
// java.sql.Blob b = (java.sql.Blob) blob;
|
return o;
|
||||||
// try {
|
} else if ((t == Long.class || t == long.class) && o instanceof Long) {
|
||||||
// o = b.getBytes(1, (int) b.length());
|
return o;
|
||||||
// } catch (Exception e) { //一般不会发生
|
|
||||||
// o = null;
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
o = (byte[]) blob;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
o = (Serializable) (index > 0 ? row.getObject(index) : row.getObject(column));
|
|
||||||
o = formatColumnValue(t, attr.genericType(), o);
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
return formatColumnValue(t, attr.genericType(), o);
|
||||||
throw new SourceException(
|
|
||||||
row.getEntityInfo() + "." + attr.field() + ".value=" + o + ": " + e.getMessage(), e.getCause());
|
|
||||||
}
|
}
|
||||||
return o;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -483,19 +483,17 @@ public class EntityBuilder<T> {
|
|||||||
Object[] cps = new Object[this.constructorParameters.length];
|
Object[] cps = new Object[this.constructorParameters.length];
|
||||||
for (int i = 0; i < constructorAttrs.length; i++) {
|
for (int i = 0; i < constructorAttrs.length; i++) {
|
||||||
Attribute<T, Serializable> attr = constructorAttrs[i];
|
Attribute<T, Serializable> attr = constructorAttrs[i];
|
||||||
if (attr == null) {
|
if (attr != null) {
|
||||||
continue;
|
cps[i] = getFieldValue(row, attr, ++index);
|
||||||
}
|
}
|
||||||
cps[i] = getFieldValue(row, attr, ++index);
|
|
||||||
}
|
}
|
||||||
obj = creator.create(cps);
|
obj = creator.create(cps);
|
||||||
}
|
}
|
||||||
if (unconstructorAttrs != null) {
|
if (unconstructorAttrs != null) {
|
||||||
for (Attribute<T, Serializable> attr : unconstructorAttrs) {
|
for (Attribute<T, Serializable> attr : unconstructorAttrs) {
|
||||||
if (attr == null) {
|
if (attr != null) {
|
||||||
continue;
|
attr.set(obj, getFieldValue(row, attr, ++index));
|
||||||
}
|
}
|
||||||
attr.set(obj, getFieldValue(row, attr, ++index));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return obj;
|
return obj;
|
||||||
|
|||||||
Reference in New Issue
Block a user